iphone - Object leak using "retain" -
i have property defined retain attribute synthesizing:
@property (nonatomic, retain) uiswitch *myswitch; and inside loadview doing this:
self.myswitch = [[uiswitch alloc] initwithframe:cgrectmake(0, 0, 40, 20)]; and inside dealloc doing this:
self.myswitch = nil; am leaking object (myswitch) have used 1 alloc? should autorelease while assigning frame?
please suggest.
the line:
self.myswitch = [[uiswitch alloc] initwithframe:cgrectmake(0, 0, 40, 20)]; actually calls retain twice- once alloc , again in assignment self.myswitch (which property you've specified should retain values assigned it.) fix have been told best add call autorelease on line, making it:
self.myswitch = [[[uiswitch alloc] initwithframe:cgrectmake(0, 0, 40, 20)] autorelease];
Comments
Post a Comment