manuelBetancurt
manuelBetancurt

Reputation: 16168

iphone dealloc property

I run the analyse build on Xcode, and get a warning for a leak because of an object that is a property and instance var

.h

UIView *_transparentView; }
    @property (nonatomic, retain) UIView *transparentView;

.m

@synthesize transparentView = _transparentView;


self.transparentView = [[UIView alloc] initWithFrame:transparentViewFrame];

- (void)dealloc {
[_transparentView release];

so I release the ivar on dealloc, but how to release the property?, [self.transparentview release] ??

Upvotes: 0

Views: 83

Answers (1)

Mousa
Mousa

Reputation: 3036

As Tom has answered replace the line that assigns the "transparentView" with:

self.transparentView = [[[UIView alloc] initWithFrame:transparentViewFrame] autorelease];

when you any value to a retained property you should you should release the assigned value if you are done with it, and release the property when deallocating the class.

Upvotes: 1

Related Questions