问题
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?
回答1:
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"
回答2:
You need to #import
the header file where that method is declared. And you need to make sure that data
is of a class for which the method is defined.
来源:https://stackoverflow.com/questions/9538884/im-getting-a-warning-using-objectfromjsondata