Reputation: 3234
When i am analyzing it getting these messages:
Method returns an Objective-C object with a +1 retain count for the below statement
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
Object leaked alocated object is not refrenced later in this execution path and has a retain count of + 1
[self.view setFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
Anyone knows how to fix these messages.
Thanks for help.
Upvotes: 0
Views: 1391
Reputation: 112855
Assuming that view
is a property with a retain
attribute self.view
retains the view so the retain created by initWithFrame
is the additional retain that needs to be released.
SImple autorelease
:
UIView *newView = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
Better yet, if possible use ARC. ARC is available for iOS 4.x and above and on a file-by-file basis for a mixed implementation. Then, there are no retain
, release
or autorelease
calls in the app.
Upvotes: 2
Reputation: 22701
self.view is a @property that is retained when it is set. You will need to release it.
Try:
UIView *newView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.view = newView;
[newView release];
or
self.view = [[[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
Upvotes: 1