I am getting this warning for the line code:
Class myClass = objc_lookUpClass([_className UTF8String]);
I am adding
#import <Foundation/NSObjCRuntime.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);
您必须导入此标头:
#import <objc/runtime.h>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.