• 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: Uli Kusterer <email@hidden>
  • Date: Sat, 19 Jul 2008 15:27:25 +0200

On 19.07.2008, at 13:03, Jean-Daniel Dupas wrote:
Because "one" don't now that "Class" are just NSObject and can be use like any other objects.


Yeah, if the sample code really is like it's actually implemented, and it wasn't simplified for posting, just placing the result of [NSlass class] into an array would be a better idea.

That said, I've implemented plugin schemes where plugin authors put the class names as strings in plist files and then we used NSClassFromString() to get the class the plugin developer requested. That's effectively what NSApplication and NSBundle do when you ask for the application class/main class to use.

Of course, stuff like that is a tad dangerous if you have to fear some other people feeding you malicious class names, so don't use NSClassFromString([NSString stringWithFormat: @"NS %@Element",currentHTMLTagName]) to implement your web browser unless you want to cope with people creating NSXMLElements for you to get your browser to crash... :-)

Cheers,
-- Uli Kusterer
"The Witnesses of TeachText are everywhere..."
http://www.zathras.de





_______________________________________________

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: Andy Lee <email@hidden>
References: 
 >substitute class at runtime? (From: Nathaniel Gottlieb-Graham <email@hidden>)
 >Re: substitute class at runtime? (From: Andy Lee <email@hidden>)
 >Re: substitute class at runtime? (From: "Kyle Sluder" <email@hidden>)
 >Re: substitute class at runtime? (From: Andy Lee <email@hidden>)
 >Re: substitute class at runtime? (From: "Kyle Sluder" <email@hidden>)
 >Re: substitute class at runtime? (From: Jean-Daniel Dupas <email@hidden>)

  • Prev by Date: Re: [SOLVED] NSButton alternate image problem - not redrawing
  • Next by Date: Re: How to get cursor text from a Mac window
  • Previous by thread: Re: substitute class at runtime?
  • Next by thread: Re: substitute class at runtime?
  • Index(es):
    • Date
    • Thread