Search code examples
iosjsonnsjsonserialization

JSON Warning in Flickr Photo Manager


I am getting a warning in my iOS app. It doesn't seem to be affecting performance in iOS 6 but my app is crashing when loading the photos from Flickr in iOS 7 beta 2 and I'm not sure if it's an issue with the beta or perhaps something to do with this warning but I'd like to get rid of the warning anyway. Any help?

Implicit conversion from enumeration type 'enum NSJSONWritingOptions' to different enumeration type 'NSJSONReadingOptions' (aka 'enum NSJSONReadingOptions')

NSError *error;
NSDictionary *results = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONWritingPrettyPrinted error:&error];

Solution

  • Pretty simple !! Just re-read the warning again. It says you are passing NSJSONWritingOptions option in options parameter while it expects NSJSONReadingOptions.

    Change your line of code as below:

    NSDictionary *results = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
    

    It should help you.