Search code examples
objective-ccompiler-warningsjsonkit

im getting a warning using objectFromJSONData


my objective C app compiles successfully, but i get an Xcode warning:

Instance method '-objectFromJSONData' not found (return type defaults to 'id')

on this line:

NSDictionary *userInfo = [data objectFromJSONData];

How can i get rid of that warning?


Solution

  • When you make a custom class or use a class built outside of apple, you need to import the headers for the framework or class you are using. This allows the compiler to cross check return types and so forth.

    When you attempt to send valid messages (but the compiler is unaware of) you will get that warning. The code should run and work with the warning there, but I am glad you want to get rid of the warning.

    in the same .m file as the code you posted... near the top... add

    #import "JSONKit.h"