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

4.8k views Asked by At

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

There are 1 answers

2
ansible On BEST ANSWER

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");        

    }        
}