3

我正在使用 FHSTwitterEngine 向 twitpic 发布 gif。当我在 iPhone 上有 wifi 或 3G 连接时,一切正常。但我也想在没有连接或上传失败时实现一些错误处理。因此,为了进行测试,我将 iphone 置于飞行模式并尝试使用以下方法上传到 twitpic:

id returned = [[FHSTwitterEngine sharedEngine] uploadImageToTwitPic:gif 
withMessage:@"message" twitPicAPIKey:@"key"];

但是当我这样做时,我立即收到以下错误:

Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'data parameter is nil'

然后 xcode 指向 FHSTwitterEngine 框架中的这行代码:

 id parsedJSONResponse = removeNull([NSJSONSerialization JSONObjectWithData:responseData 
options:NSJSONReadingMutableContainers error:nil]);

关于如何解决这个问题的任何想法?

4

1 回答 1

7

您可以先检查互联网连接。

Reachability *networkReachability = [Reachability reachabilityForInternetConnection];   
NetworkStatus networkStatus = [networkReachability currentReachabilityStatus];    
if (networkStatus == NotReachable) {        
    NSLog(@"There IS NO internet connection");        
} else {        

     NSLog(@"There IS internet connection");        

    }        
}
于 2014-01-23T15:31:02.470 回答