On Aug 8, 2008, at 8:33 AM, Uli Kusterer wrote:

On 08.08.2008, at 07:28, Nick Zitzmann wrote:

On Aug 7, 2008, at 11:08 AM, Lee, Frederick wrote:

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

Because class methods other than +new return autoreleased objects, which makes non-GC memory management a little bit easier.

This is simply wrong. Ignore that. A counterexample would be +alloc. Better read Apple's memory management rules if you want to know the correct story.

As a blanket rule, sure. However, classes will often define class methods that act as conveniences for the longer instance initializers. Consider NSArray:

        + (id) arrayWithArray:(NSArray *) array
        - (id) initWithArray:(NSArray *) array

Both of these follow the normal memory management rules, so +arrayWithArray: returns an autoreleased object, while -initWithArray: doesn't, so these two expressions are equivalent:

        [NSArray arrayWithArray:x]
        [[[NSArray alloc] initWithArray:x] autorelease]

Presumably this is what Mr. Zitzmann was referring to.


--Chris N.
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

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/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to