• 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: Regarding MVC design pattern
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Regarding MVC design pattern


  • Subject: Re: Regarding MVC design pattern
  • From: Kyle Sluder <email@hidden>
  • Date: Wed, 19 May 2010 10:12:59 -0700

On Wed, May 19, 2010 at 4:38 AM, Sherm Pendley <email@hidden> 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:

But you shouldn't be using accessors in -init or -dealloc anyway. It
makes subclassing fragile. Unless, of course, you make the accessor's
behavior an explicit part of your subclassing contract so both sides
can handle being partially initialized or deallocated. But on the
whole it's just easier not to use accessors in -init and -dealloc.

If you synthesize your ivars, you can get at the ivar using the self-> syntax.

@interface MyClass

@property(retain) id myFoo;

- (id)initWithFoo:(id)aFoo;

@end

@implementation MyClass

@synthesize myFoo;

- (id)initWithFoo:(id)aFoo {
  if (!(self = [super init]))
    return nil;

  self->myFoo = [aFoo retain];

  return self;
}

- (void)dealloc {
  [self->myFoo release];
  [super dealloc];
}

--Kyle Sluder
_______________________________________________

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

  • Follow-Ups:
    • Re: Regarding MVC design pattern
      • From: Alexander Spohr <email@hidden>
References: 
 >Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Henry McGilton <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Jack Nutting <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Kyle Sluder <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sai <email@hidden>)
 >Re: Regarding MVC design pattern (From: Jack Nutting <email@hidden>)
 >Re: Regarding MVC design pattern (From: Joanna Carter <email@hidden>)
 >Re: Regarding MVC design pattern (From: Sherm Pendley <email@hidden>)

  • Prev by Date: Re: singleton design pattern
  • Next by Date: Re: iPhone/iPad: Desktop wallpaper can't be set.
  • Previous by thread: Re: Regarding MVC design pattern
  • Next by thread: Re: Regarding MVC design pattern
  • Index(es):
    • Date
    • Thread