im getting a warning using objectFromJSONData

妖精的绣舞 提交于 2019-12-12 03:09:57

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!