Reputation:
Is there an equivalent of selectors for classes? How can I create a instance of a class from a string?
Upvotes: 5
Views: 2417
Reputation: 81052
You want NSClassFromString
.
NSString *theClassForMe = @"NSMutableArray";
id newObject = [[NSClassFromString(theClassForMe) alloc] init];
Upvotes: 13