iOS Dropbox SDK on Device fails login with NSURLErrorDomain

放肆的年华 提交于 2020-01-01 19:20:53

问题


UPDATE: Setting the Dropbox SDK to use HTTP instead of HTTPS cures this problem on an iPhone 3G. I haven't used the SDK on iPhone 4 or iPad yet so I'm not sure of the result.

Playing with the Dropbox SDK on iOS yields these results: in simulator, I can properly link my account using the provided login form class. Changing the build setting to device, I get an error alertView triggered by this method in DBLoginController.m

- (void)restClient:(DBRestClient*)client loginFailedWithError:(NSError*)error {
    [self setWorking:NO];
    NSString* message;
    if ([error.domain isEqual:NSURLErrorDomain]) {
        message = @"There was an error connecting to Dropbox.";
    } else {
        //...

The login form is displayed like so, as referenced in the included sample project:

-(void)settingsPressed {
if (![[DBSession sharedSession] isLinked]) {
        DBLoginController* controller = [[DBLoginController new] autorelease];
        controller.delegate = self;
        [controller presentFromController:self];
    } else {
        [[DBSession sharedSession] unlink];
        [[[[UIAlertView alloc] 
           initWithTitle:@"Account Unlinked!" message:@"Your dropbox account has been unlinked" 
           delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]
          autorelease]
         show];
        [self updateButtons];
    }

}

I'm not sure what to make of this. Apple docs suggest that NSURLErrorDomain is defined as NSURL loading system errors. Can anyone shed light on that?


回答1:


What you should look at is error.code or better [error localizedDescription]

NSURLErrorDomain is a vast error domain :

Constants used by NSError to differentiate between "domains" of error codes, serving as a discriminator for error codes that originate from different subsystems or sources

An error in NSURLErrorDomain could be almost anything, connection down, proxy, certificate errors... Search for NSURLError in that apple documentation page.



来源:https://stackoverflow.com/questions/5643493/ios-dropbox-sdk-on-device-fails-login-with-nsurlerrordomain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!