• 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: Cocoa Dev Style: Using Class versus Object Methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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

References: 
 >Cocoa Dev Style: Using Class versus Object Methods (From: "Lee, Frederick" <email@hidden>)
 >Re: Cocoa Dev Style: Using Class versus Object Methods (From: Nick Zitzmann <email@hidden>)

  • Prev by Date: Re: CGImageSourceCreateFromURL failed with error -11
  • Next by Date: Re: Application control
  • Previous by thread: Re: Cocoa Dev Style: Using Class versus Object Methods
  • Next by thread: Re: Cocoa Dev Style: Using Class versus Object Methods
  • Index(es):
    • Date
    • Thread