• 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: Ian Joyner <email@hidden>
  • Date: Fri, 8 Aug 2008 23:26:29 +1000

It's not style, but a technical consideration. Class-level things are shared and common between all object instances. They are thus like globals, but obviously better organized. Class-level methods cannot access things at the object level. Objects have their own different values of attributes.

Putting things on the stack is only an optimization which some OO languages let you do, if you know certain conditions will be met.

Ian

On 08/08/2008, at 3:08 AM, Lee, Frederick wrote:

Greetings:

   I just came across a NSObject subclass written by someone, that
contains a couple of date/Time-processing methods (stringToDate,
visa-versa).

The methods were all class-level methods (+) vs (-); and hence, didn't
require the familiar alloc & init instantiation methods.



I've been writing NSObjects via instantiation (requiring alloc & init)
that I use to model business logic (packing XML data vectors, etc.) and
hold a lot of common methods to use.




I can see a project using class methods instead of instantiated methods;
and hence, avoid the alloc/init memory hassles.




My question (which is ELEMENTARY), is....

1) why use instantiated objects versus classes (via class methods)?

2)      Are classes stored in the stack & instatiated objects on the
heap?





Ric.



_______________________________________________

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
_______________________________________________

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>)

  • Prev by Date: Re: how to have a pop up menu from an ordinary button?
  • Next by Date: Lazy Loading of images
  • Previous by thread: Re: Cocoa Dev Style: Using Class versus Object Methods
  • Next by thread: Application control
  • Index(es):
    • Date
    • Thread