Sunday, November 8, 2009

Creating an instance of a class from a string

If you need to create an instance of an Objective C class from a string indicating the class' name:


if (NSClassFromString(className) != nil) {
id theInstance = [[NSClassFromString(className) alloc] init] autorelease];
}

No comments:

Post a Comment