Re: substitute class at runtime?
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