Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: substitute class at runtime?



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:
http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to 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>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.