Re: NSClassFromString()
Re: NSClassFromString()
- Subject: Re: NSClassFromString()
- From: David Remahl <email@hidden>
- Date: Tue, 10 Dec 2002 05:57:29 +0100
Mark,
The function does indeed consume a noticable amount of processing power
and calling it a lot may have a negative impact on the performance.
However, the penalty is only incurred when it is called, not when using
the returned Class, of course.
So, if you are going to use a class for which you only have an NSString
name in a loop, then you should probably cache it. Calling
NSClassFromString() takes the equivalent of quite a few method calls,
according to my quick sample program. However, I don't think it is
_necessary_ to cache it if you are only going to use it a few times.
In this case and in most others the general principle of first writing
clear code, and then profiling it and optimize based on the profiling
data applies. That methodology allows you to find and eliminate the
real bottle-necks instead of focusing on optimizations that don't
really give anything.
/ Regards, David Remahl
On Tuesday, December 10, 2002, at 05:03 AM, Mark Levin wrote:
How fast is this function, in general? Is it appropriate for
performance-oriented code? Or is it worth precaching the class objects
myself?
--Mark
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.