• 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
Fwd: retain and don`t retain in accessor methods
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Fwd: retain and don`t retain in accessor methods


  • Subject: Fwd: retain and don`t retain in accessor methods
  • From: Ariel Feinerman <email@hidden>
  • Date: Sun, 15 Nov 2009 00:35:56 +0200

Hi,
I need two versions of -initWith ... and -set ... methods of custom timer
class (for example, to prevent the circle references);
Is these correct implementation?

- (id) initWithTarget: (id) theTarget {

 return [self initWithTarget: theTarget retain: YES]; // ?

}


- (id) initWithTarget: (id) theTarget retain: (BOOL) theflag {

 if (self = [super init]) {

if ([self setTarget: theTarget retain: theflag]) {

time = 1.0 / 1000.0;

[self begin];

}

else

[self release];

}

 return self;

}


- (BOOL) setTarget: (id) theTarget {

 return [self setTarget: theTarget retain: YES]; // ?

}


- (BOOL) setTarget: (id) theTarget retain: (BOOL) theflag {

 if ([theTarget respondsToSelector: @selector(refresh)]) {

if (flag && target)

[target release];

if (theflag)

[theTarget retain];

target = theTarget;

 flag = theflag;

return YES;

}

return NO;

}
_______________________________________________

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: retain and don`t retain in accessor methods
      • From: Kyle Sluder <email@hidden>
  • Prev by Date: Re: vImage Help
  • Next by Date: Re: retain and don`t retain in accessor methods
  • Previous by thread: Re: vImage Help
  • Next by thread: Re: retain and don`t retain in accessor methods
  • Index(es):
    • Date
    • Thread