Reputation: 16051
346 - NSFileManager *fileManager = [[NSFileManager alloc] init];
347 - [fileManager removeItemAtPath:[mediaSource.newMediaToDelete objectAtIndex:i] error:nil];
348 - [fileManager release];
The error points towards line 348 and says:
'Potential leak of an object allocated on line 347'
I don't understand this, obviously line 347 isn't an allocation, and the allocation on line 346 is already released.
Upvotes: 0
Views: 107
Reputation: 840
Have you tried to click on the error message itself? Those arrows which show you the path of your problem are sometimes very useful. I guess it is the mediaSource or newmediaToDelete object which causes the message.
Upvotes: 0
Reputation: 7072
Avoid using the 'new' or 'create' in your own method names (unless they return objects that are not autoreleased I guess). It confuses the static analyser. I've had this issue and found it went away when I changed my method name.
Update: I see Bavarious has already noted this in the comments.
Upvotes: 2
Reputation: 11053
I tried the following code and did not get any warning:
NSInteger i = 0;
NSArray *ax = [NSArray arrayWithObjects:@"a",@"b",@"c",nil];
NSFileManager *fileManager = [[NSFileManager alloc] init];
[fileManager removeItemAtPath:[ax objectAtIndex:i] error:nil];
[fileManager release];
So it must be with returned mediaSource.newMediaToDelete object...
try a var assignemnt like:
x = [mediaSource.newMediaToDelete objectAtIndex:i];
and it should show there...
Upvotes: 0
Reputation: 540
May be in NSArray mediaSource.newMediaToDelete objects are not autorelease?
Upvotes: 0