Can anyone explain to me why Analyze gives me a memory leak warning for (nonatomic, assign) “newNonStaleStories” on the return statement here:
-(NSArray *)newNonStaleStories
{
@synchronized (LIBRARY_ACCESS_LOCK)
{
newNonStaleStories = [self.managedObjectContext executeFetchRequest:self.newNonStaleStoriesInDescendingIndexOrderFetchRequest error:nil];
}
return newNonStaleStories;
}
but does not give any warning for (nonatomic, assign) “staleStories” here:
-(NSArray *)staleStories
{
@synchronized (LIBRARY_ACCESS_LOCK)
{
staleStories = [self.managedObjectContext executeFetchRequest:self.staleStoriesInDescendingIndexOrderFetchRequest error:nil];
}
return staleStories;
}
In fact, there are several other property getter methods in this same class that use exactly the same pattern, and none of them have memory warnings either.
(FWIW, “managedObjectContext” and the fetch requests in each case are (nonatomic, retain).)
Thanks!
P.S. This is in the current (v.4.1) Mac App Store release of Xcode for Lion
Because the name is prefixed with “new” and the Memory Management Rules state that the caller of a method whose name begins with “new” owns the returned object.