Re: substitute class at runtime?
Re: substitute class at runtime?
- Subject: Re: substitute class at runtime?
- From: Andy Lee <email@hidden>
- Date: Fri, 18 Jul 2008 14:05:42 -0400
NSClassFromString()
--Andy
On Jul 18, 2008, at 2:00 PM, Nathaniel Gottlieb-Graham wrote:
I need to be able to initialize a class, but I don't necessarily
know what kind of class it'll be at compile time. Consider the
following example in which the name of a class is checked against an
array of class names, and if the name of the class is present in the
array, a new instance of that class is initialized:
NSString *nameOfClass = fooViewController
NSArray *classNameArray = [NSArray arrayWithObjects:
@"FooViewController", @"BarViewController", nil];
if ([classNameArray containsObject:nameOfClass])
{
[[[??????? alloc]initWithNibName:nameOfClass] autorelease]
}
How can I get the class name into the ??????? part?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden