You do not check if your responseData zero or not before passing it to the JSONObjectWithData:options:error: method.
You should probably try the following:
- (void)receiveLatest:(NSData *)responseData { //parse out the json data NSError* error; if(responseData != nil) { NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error]; NSString *Draw_539 = [json objectForKey:@"Draw_539"]; } else { //Handle error or alert user here } .... }
EDIT-1: For good practice, you should check this error object after the JSONObjectWithData:options:error: method to check and verify whether the JSON data was successfully converted to NSDictionary or not.
- (void)receiveLatest:(NSData *)responseData { //parse out the json data NSError* error; if(responseData != nil) { NSDictionary* json = [NSJSONSerialization JSONObjectWithData:responseData options:kNilOptions error:&error]; if(!error) { NSString *Draw_539 = [json objectForKey:@"Draw_539"]; } else { NSLog(@"Error: %@", [error localizedDescription]); //Do additional data manipulation or handling work here. } } else { //Handle error or alert user here } .... }
Hope this solves your problem.
Let me know if you need more help.
source share