If you need to have it set you should create an initWithOptionName: and call that from your standard init, or return an error stating a missing value is needed.

Your init should always call down tithe most specific init.

Specific examples of this are available as best practice in several cocoa and design pattern books.

Sent from my iPhone

On May 20, 2010, at 9:40 AM, Thomas Davie <tom.da...@gmail.com> wrote:


On 20 May 2010, at 15:24, mmalc Crawford wrote:


On May 19, 2010, at 4:38 am, Sherm Pendley wrote:

If you set the ivars directly, as above, the synthesized setters will
NOT be called. For that to happen, you need to use dot-syntax, like
this:

- (void) dealloc {
 self.beginButton = nil;
 self.endButton = nil;
 // etc...
 [super dealloc];
}

You do not *need* to use the dot syntax to invoke the accessors synthesised for a property. You can also use the corresponding accessor method using [] syntax, e.g.

   [self setBeginButton:nil];

However, you should typically not invoke accessor methods in init or dealloc methods.

Can I ask why you shouldn't use them in init? It makes a lot of sense to not use them in alloc/dealloc, but I'm not using them in init... after all, what if I replace the ivar with a derived property from another object? Why should I have to recode my init?

Bob_______________________________________________

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/atri%40me.com

This email sent to a...@me.com
_______________________________________________

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 arch...@mail-archive.com

Reply via email to