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

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.

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];

Related

How to fix "nsurlconnection finished with error - code 1100 " error for UIWebView in IOS?

I am working on an existing project where UIWebview is used to load html string to load js files for loading contents downloaded from our server.Currently UIWebview is not able to load the contents in IOS which is perfectly loading in Android.
I have tried to switch to WKWebView but still no luck.
self.webContentView.delegate = self;
NSString* html = [player getHTMLString];
NSString* baseURL = [player getBaseURLPath];
[self.pageLoadingActivity startAnimating];
[self.webContentView loadHTMLString:html baseURL: [NSURL URLWithString: baseURL]];
EDIT------
After debugging sometime I found I was getting two 1100 error.
It seemed like two file were missing or app was not able to read them.
Now whenever I am hitting shouldStartLoadWithRequest with
request
URL:
file:///Users/ealpha4tech/Library/Developer/CoreSimulator/Devices/2CA71983-9996-44D6-944F-34E3EAFAE96D/data/Containers/Data/Application/6A19ABBA-CB68-4EE4-AC02-6AD3CB8A5A68/Documents/icplayer/icplayer/D2D6AFFF93CB2CFCB1640484F5429D89.cache.html
I am getting 1100 error.(the above file is present though)
So as a guess, I would say [player getHTMLString] is the problem.
NSURLErrorFileDoesNotExist: The specified file doesn’t exist.
This is a local file error.
I'm guessing that -getHTMLString is trying to load a file out of the app, but that file is not being included in the app.
I could help more if you provide 2 things.
Provide the source for -getHTMLString
Use NSLog() to print value of [player getBaseURLPath].
UPDATE
In looking at your output, I noticed …ments/icplayer/icplayer/D2D6A…. I think the proper path should only have one icplayer not two. Look to see if it's getting repeated somehow.

gtm-oauth2 crash on Mac OSX when authenticating with Instagram API

I'm building a small Instagram client for personal use on Mac OSX. I'm currently using gtm-oauth2 to obtain an oauth2 token from Instagram. I'm following the guide provided with the source to obtain this token. I've got it 90% working. The webView loads with the authentication details, and I can enter my account and the permissions screen comes up asking if I would like to grant my application access. The issue I'm running into is that after authenticating, regardless of whether I "Allow" or "Cancel", the application crashes with no stack trace or additional information. The only info I get regarding the exception is "Thread 1: EXC_BAD_ACCESS (code = 1, address=0x4c1)" and it appears that the thread is doing something to do with the WebCore::ResourceLoader, but it's a bunch of ASM so I've got no idea where this call is actually occurring. Perhaps I'm not calling the windowController properly? I've got my code included below.
- (void)signIntoInstagram {
NSURL *tokenURL =[NSURL URLWithString:kTOKENIURl];
// Set up the OAuth request
GTMOAuth2Authentication *auth = [GTMOAuth2Authentication
authenticationWithServiceProvider:#"Instagram"
tokenURL:tokenURL
redirectURI:kREDIRECTURI
clientID:KCLIENTID
clientSecret:KCLIENTSERCRET
];
// Specify the appropriate scope string, if any, according to the service's API documentation
auth.scope = #"basic";
NSURL *authURL = [NSURL URLWithString:KAUTHURL];
// Display the authentication view
GTMOAuth2WindowController *windowController;
windowController = [GTMOAuth2WindowController controllerWithAuthentication:auth
authorizationURL:authURL
keychainItemName:kKeychainItemName
resourceBundle:nil];
// optional: display some html briefly before the sign-in page loads
NSString *html = #"<html><body><div align=center>Loading sign-in page...</div></body></html>";
[windowController setInitialHTMLString:html];
[windowController signInSheetModalForWindow:_window
delegate:self
finishedSelector:#selector(windowController:finishedWithAuth:error:)];}
If I insert a breakpoint within the windowController:finishedWithAuth:error: method, the application is reaching it. However, it still crashes after I run through, which to me seems like some sort of asynchronous operation causing the error. Hopefully I'm just missing something simple here; I can't imagine there is a major flaw in Google's OAuth project.
I found this on a Google group after having the same problem https://groups.google.com/forum/#!msg/gtm-oauth/N6jlOpL9k5g/n4TdrTJyxzcJ . There is also an issue logged for it https://code.google.com/p/gtm-oauth/issues/detail?id=11
Basically I commented out line 331 of GTMOAuth2WindowController.m and it worked. You can also add your vote to the issue and maybe Google will fix it.

dispatch_once in ShareKit causing crash

I was using ShareKit for a p long time, without downloading last updates from its repository.
Now i need some of its new features, so i've pulled all last commits and tried to run my app with new ShareKit without making any changes to my code (except some small changes in includes).
App compiles without errors but when i try to execute usual Facebook sharing code - it crashes without any useful error description.
old code i want to get to work
NSURL *url = [NSURL URLWithString:[NSString stringWithUTF8String:sk::game_services::get_app_store_url()]];
SHKItem *item = [SHKItem URL:url title:[NSString stringWithUTF8String:message] contentType:SHKURLContentTypeWebpage];
[SHKFacebook shareItem:item];
and according to updated ShareKit demo app and its documentation - this code should still work.
but it doesn't
it horribly crashes in currentIndicator method of SHKActivityIndicator inside macro DEFINE_SHARED_INSTANCE_USING_BLOCK that contains dispatch_once call.
debugger just says "SIGABRT" and thats all.
i don't know what to do.

Catching errors with setMainFrameURL in a Webview

I am using the following code to populate a webView in my Mac app...
NSURL *url = [NSURL URLWithString:#"https://joeworkman.net"];
[self setMainFrameURL:[url absoluteString]];
I would like to be able to capture when there are errors loading this URL and then instead load a local HTML file stored within my app. This way the users gets presented with a presentable error instead of an ugly 500 server error (if that was the case). Not to mention that most users would not know what that meant anyhow.

Facebook iOS SDK error when requesting user info

I'm working on an iPhone application and part of it relies on Facebook integration. I downloaded version 3.1 of the SDK from the website and followed the first tutorial, found at this link: Authenticate.
I'm using iOS 6.0.1 on an iPhone 4 and Xcode 4.5.
Although the login works fine, when following the steps here in order to request basic user information, the application gives the following error:
2013-01-01 23:13:57.966 AppName[8691:907] Error: HTTP status code: 400
2013-01-01 23:13:57.977 AppName[8691:907] FBSDKLog: Response <#1111> <Error>:
The operation couldn’t be completed. (com.facebook.sdk error 5.)
This is the code I'm using to request the information:
if (FBSession.activeSession.isOpen) {
[FBSettings setLoggingBehavior:[NSSet setWithObjects:
FBLoggingBehaviorFBRequests, nil]];
[[FBRequest requestForMe] startWithCompletionHandler:^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *aUser,
NSError *error) {
if (!error) {
NSLog(#"%#", [[FBSession activeSession] accessToken]);
userProfileImage.profileID = aUser.id;
self.user = [[User alloc] initWithName:aUser.name andLocation:[aUser.location objectForKey:#"name"]];
[self.user saveUser];
[nameTextField setText:[self.user getName]];
[locationTextField setText:[self.user getLocation]];
}
}];
}
The weird part is that the FBRequest works in the simulator. I checked the access token and I get one on the iPhone too.
One other thing that might be important: On the simulator the application redirects to the Facebook website where it gets authorized(I can view it in my app list on Facebook). On the other hand, when logging in from the device, I only get a standard alert the first time I login and the app doesn't get added on Facebook.
P.S.: This is my first question, so I apologize for the amount (or lack) of information. Thank you in advance for helping me out!
I have been frantically scouring Google for an answer to this for the last couple of days and couldn't find an answer. It was very upsetting, not necessarily because of the bug itself, but because so many people had it, but so few actual answers were given.
The error seems to be a permission issue. If you login from iOS 6, then delete the app from your Facebook, the device will still think you gave the app authorization, thus returning the error. The best answer I could find was here.
Today, after I loaded the app on the device again, without trying the simulator first, it worked like a charm. My advice if you have the same issue is to work on some other code for a while and try again the following day. It's not the perfect solution and I think Apple/Facebook should try and fix that, but it works.