Getting null back from XML, but only on wi-fi only devices

105 Views Asked by At

I have an app that incorporates weather...data that I receive from Google's weather API. I'm busting my brain trying to figure out a problem that I'm having and I've been unsuccessful so I figured it was time to ask around on here.

Here is my code:

query = [[NSString stringWithFormat:@"%@",query] stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSLog(@"query: %@",query);

// SET GOOGLE WEATHER XML LOCATION
CXMLDocument *parse = [[CXMLDocument alloc]initWithContentsOfURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://www.google.com/ig/api?weather=%@", query]]options:0 error:nil];
NSLog(@"URL: %@", parse);

The query variable holds my reverse geocoder location (e.g. Chicago,IL) for which I append it to the Google URL to get the XML back.

As you can see I'm logging out both the query and the parse variables. I can see that I'm getting a legit query location for my current location when the code is executed, but by the time I log the parse variable I get nothing. The parse logging shows null...nothing was returned from Google. I can see that the URL is correct and I can even go to my browser and get the data I need by using the same logged link.

Interestingly enough...it works perfectly in the simulator and it also works just fine on my iPhone running 5.1.1. I do have iOS6b4 installed on my iPad which is giving the issue, but since I'm not using any new code that was introduced in iOS6 it shouldn't cause any issues here.

Any ideas as to why the XML parsing refuses to work on a wi-fi only iPad?

BTW, before anyone tells me to start using NSXMLParser instead of TouchXML...I do have a test version that runs NSXMLParser instead and I'm getting the same issue there as well. I'm at a loss.

1

There are 1 best solutions below

0
On

I finally figured this out...it actually had to do with the locationManager.

I had the following code:

 if ([locationManager respondsToSelector:@selector(startMonitoringSignificantLocationChanges)]) {
    [locationManager startMonitoringSignificantLocationChanges]; }
 else {
     [locationManager startUpdatingLocation]; }

Getting rid of the if/else statement and just going with the following resolved it:

[locationManager startUpdatingLocation];