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 (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