Reputation: 39374
In my application I m using following code below:-
NSArray* toolbarItems = [NSArray arrayWithObjects:
[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(done)], nil];
[toolbarItems makeObjectsPerformSelector:@selector(release)];
For that it shows Potential leak of an object .
Upvotes: 3
Views: 1680
Reputation: 185
When you create an array using arrayWith... the object is autorelease so you don't need to release the object. you do release when you create objects with the [[alloc] init] style
Upvotes: 1
Reputation: 243156
Yes that's a potential leak because you created a UIBarButtonItem
that you owned (since you invoked alloc
), but lost the reference to it by directly putting it into the array. As such, the analyzer is reporting that you leaked it.
Besides that, the code is terrible. I can't think of any valid situation where you'd ever want to do [anArray makeObjectsPerformSelector:@selector(release)];
Upvotes: 5