开发者

implicit declaration of function 'objc_lookUpClass'

I am getting this warning for the line code:

Class myClass = objc_lookUpClass([_className UTF8String]);

I am adding

#import <Foundation/N开发者_JAVA技巧SObjCRuntime.h>
#import <objc/objc.h>

And it still don't resolve the problem

Another warning i get on this line is: "Initialization makes pointer from integer without a cast"


If you check the doc, you'll see that objc_lookUpClass returns an id, not a Class. To suppress the warning you either need to make myClass an id, or cast the return value to a Class:

Class myClass = (Class)objc_lookUpClass([_className UTF8String]);

BTW, there is NSClassFromString if you have an NSString.

Class myClass = NSClassFromString(_className);


You have to import this header:

#import <objc/runtime.h>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜