substitute class at runtime?
Subject : substitute class at runtime?
From: Nathaniel Gottlieb-Graham <email@hidden >
Date: Fri, 18 Jul 2008 14:00:22 -0400
Delivered-to: email@hidden
Delivered-to: email@hidden
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:from:to :content-type:content-transfer-encoding:mime-version:subject:date :x-mailer; bh=grgEN49cT8eAffIl9fhHvG1J+sYY+s0Z7dcnjI61llI=; b=AGyGGqN3yz8UwoJ3y36Ayk/Nk1Jdwj8rj3uKOuCzJPyRRY8TVgyt5n2Mwb7LWXMRtx AqaOVX3J3pb7DT7RpOrbIxF5uU8KL3prv0yeQxLR3MeGt0GCGdWQ94WlOn2ss4Rx/PEX jRPlHGItPlXvXqjhWcEm/zTgDs8FKucEtmYSo=
Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:from:to:content-type:content-transfer-encoding :mime-version:subject:date:x-mailer; b=AG8euNltBHdOmza+Rvw4JCybUDc6jkoX1FSVJ4MVt8T8NWMbf82suBg/3VG0ZYgR06 Gd91t1KA2aSAYk7pwuO9DjO8WE3NkcP587+xxgHLJETWZVlrVq1W0943i0ZDzTUzQygz ObZ6nare760gSIeatrH/u3JPMdwC/1G3qjs4w=
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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden
This email sent to email@hidden
Visit the Apple Store online or at retail locations.
1-800-MY-APPLE
Contact Apple | Terms of Use | Privacy Policy
Copyright © 2007 Apple Inc. All rights reserved.