Re: Cocoa Dev Style: Using Class versus Object Methods
Re: Cocoa Dev Style: Using Class versus Object Methods
- Subject: Re: Cocoa Dev Style: Using Class versus Object Methods
- From: "Shawn Erickson" <email@hidden>
- Date: Fri, 8 Aug 2008 08:16:56 -0700
On Thu, Aug 7, 2008 at 10:28 PM, Nick Zitzmann <email@hidden> wrote:
>
> Because class methods other than +new return autoreleased objects, which
> makes non-GC memory management a little bit easier.
This isn't very accurate statement (for a few reasons) ... IMHO it
would be better left unstated.
> On Aug 7, 2008, at 11:08 AM, Lee, Frederick wrote:
>
>> 1) why use instantiated objects versus classes (via class methods)?
One example... you could make a method a class method if the method
didn't have to access any instance related variables (ivars). In other
words it could operate on the data you pass it as parameters without
having to have any storage of its own (ignoring the possible use of
function static vars).
Good way (as others noted) to make available utility code that is not
instance specific in a nicely name spaced fashion.
I suggest looking around the Cocoa framework API documentation at all
of the class methods it provides for a better idea of when / why you
could use one.
-Shawn
_______________________________________________
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