5

Is there an equivalent of selectors for classes? How can I create a instance of a class from a string?

1 Answer 1

13

You want NSClassFromString.

NSString *theClassForMe = @"NSMutableArray";
id newObject = [[NSClassFromString(theClassForMe) alloc] init];
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.