FHSTwitterEngine - 'NSInvalidArgumentException','data parameter is nil'

一笑奈何 提交于 2019-12-10 10:24:33

问题


I'm using FHSTwitterEngine to post a gif to twitpic. When I have a wifi or 3G connection on the iphone everything works fine. But I also want to implement some error handling for when there is no connection or when the upload failed. So for testing I put the iphone in airplane mode and try to upload to twitpic using the following method:

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

but when I do that I immediately get the following error:

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

then xcode points to this line of code in the FHSTwitterEngine framework:

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

any ideas on how to solve this?


回答1:


You could check for internet connectivity first.

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

     NSLog(@"There IS internet connection");        

    }        
}


来源:https://stackoverflow.com/questions/21311760/fhstwitterengine-nsinvalidargumentexception-data-parameter-is-nil

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