• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: substitute class at runtime?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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


  • Follow-Ups:
    • Re: substitute class at runtime?
      • From: "Kyle Sluder" <email@hidden>
References: 
 >substitute class at runtime? (From: Nathaniel Gottlieb-Graham <email@hidden>)

  • Prev by Date: substitute class at runtime?
  • Next by Date: Re: substitute class at runtime?
  • Previous by thread: substitute class at runtime?
  • Next by thread: Re: substitute class at runtime?
  • Index(es):
    • Date
    • Thread