Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: initializers in Categories?





On Jul 13, 2006, at 12:33 PM, A.M. wrote:

On Thu, July 13, 2006 3:07 pm, Rob Ross wrote:
Can a category declare a new initializer for an object?


ie,

@interface Foo (MyCategory)


- (id) initWithSomeNewArgumentList:(Bar *)bar :(Baz *)baz;


@end

Yes. You can essentially repoint arbitrary methods with a category, but
that is almost certainly not what you want. What is it that you wish to
accomplish?


-M


I wasn't talking about overriding an existing -init method (although that's another good question - should you?), I was talking about *adding* new initializers via a Category.

At this point, all I'm trying to accomplish is learn all the ways that Categories can be used ;)

They're a new concept for me, so I'm just trying to see where the boundaries are.

The only thing I can think of at the moment is perhaps you have a class with a lot of ivars and accessors, and you want to use a group of them in some part of your code, and rather then having to make a lot of [... setXXX] calls, create a convenience initializer that will initialize the set of ivars you care about in one call.



Rob Ross, Lead Software Engineer
E! Networks

---------------------------------------------------
"Beware of he who would deny you access to information, for in his heart he dreams himself your master." -- Commissioner Pravin Lal



_______________________________________________ Do not post admin requests to the list. They will be ignored. Cocoa-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/cocoa-dev/email@hidden

This email sent to email@hidden
References: 
 >initializers in Categories? (From: Rob Ross <email@hidden>)
 >Re: initializers in Categories? (From: "A.M." <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.