• 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
substitute class at runtime?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

substitute class at runtime?


  • Subject: substitute class at runtime?
  • From: Nathaniel Gottlieb-Graham <email@hidden>
  • Date: Fri, 18 Jul 2008 14:00:22 -0400

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


  • Follow-Ups:
    • Re: substitute class at runtime?
      • From: Nick Zitzmann <email@hidden>
    • Re: substitute class at runtime?
      • From: Andy Lee <email@hidden>
  • Prev by Date: Re: NSMutableDictionary autorelease chrashes application
  • Next by Date: Re: substitute class at runtime?
  • Previous by thread: Re: Xcode3 vs Xcode2 - two problems
  • Next by thread: Re: substitute class at runtime?
  • Index(es):
    • Date
    • Thread