简体   繁体   中英

How to fast enumerate through an array of objects of type `NSClassFromString(className)`?

Class class = NSClassFromString(className);
for (class *object in fetchedObjects) {

}

Hey guys! So I have the above code inside a method that accepts a class name and it doesn't work for some reason. It tells me "Use of undeclared identifier 'object' Anybody know what I can do to fix this? :\\ It should be the same as saying:

for (NSObject *object in fetchedObjects) {

}

Use id instead of NSObject

Class class = NSClassFromString(className);
for (id object in fetchedObjects) {

}

Note that variables of type id aren't declared with an asterisk ( * ).

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM