iphone - release or not release -


i'm developing iphone application.

i have following property:

@property (nonatomic, retain) point2d* endpoint; 

and method on same class:

- (id)initwithx:(cgfloat)x y:(cgfloat)y; {     if (self = [super init])     {         endpoint = [[point2d alloc] initwithx:x y:y];      ... } 

and dealloc method on same class:

- (void)dealloc {     [endpoint release];     [super dealloc]; } 

my question code correct?

endpoint = [[point2d alloc] initwithx:x y:y]; 

or maybe have autorelease here.

your assignment

endpoint = [[point2d alloc] initwithx:x y:y];

does not increase retaincount, if want keep endpoint use later don't use autorelease here.

or can use

self.endpoint = [[[point2d alloc] initwithx:x y:y] autorelease];

=> assignment increase counter of endpoint.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -