• 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: Constructing class names dynamically
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Constructing class names dynamically


  • Subject: Re: Constructing class names dynamically
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Tue, 13 Jan 2009 22:33:45 +0100


Le 13 janv. 09 à 22:29, Bill Bumgarner a écrit :

On Jan 13, 2009, at 1:18 PM, Mohan Parthasarathy wrote:
Does this make sense ?

Yes.

Or this is a bad idea ?

Yes.

Generally, anyway, it is indicative of bad design when your code seems to require dynamic generation of classes.


he is just talking about class name, not class.

NSClassFromString() is probably what you're looking for.

NSMutableString *clsName = derive class name from the entry.

Class cls = NSClassFromString(clsName);

id<YouProtocol> instance = [[cls alloc] init];


_______________________________________________

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: Constructing class names dynamically
      • From: Ken Thomases <email@hidden>
    • Re: Constructing class names dynamically
      • From: Bill Bumgarner <email@hidden>
References: 
 >Constructing class names dynamically (From: "Mohan Parthasarathy" <email@hidden>)
 >Re: Constructing class names dynamically (From: Bill Bumgarner <email@hidden>)

  • Prev by Date: Re: Constructing class names dynamically
  • Next by Date: Aquatic Prime + PayPal With Multiple Apps?
  • Previous by thread: Re: Constructing class names dynamically
  • Next by thread: Re: Constructing class names dynamically
  • Index(es):
    • Date
    • Thread