Core Data produces Analyzer warnings
Posted
by
RickiG
on Stack Overflow
See other posts from Stack Overflow
or by RickiG
Published on 2011-01-04T13:42:36Z
Indexed on
2011/01/04
13:54 UTC
Read the original article
Hit count: 229
Hi
I am doing the final touch ups on an app and I am getting rid of every compiler/analyzer warning.
I have a bunch of Class methods that wrap my apps access to Core Data entities. This is "provoking" the analyzer.
+ (CDProductEntity*) newProductEntity {
return (CDProductEntity*)[NSEntityDescription insertNewObjectForEntityForName:@"CDProductEntity" inManagedObjectContext:[self context]];
}
Which results in an Analyzer warning:
Object with +0 retain counts returned to caller where a +1 (owning) retain count is expected
In the method that calls the above Class Method I have this:
CDProductEntity *newEntity = [self newProductEntity];
Which results in an Analyzer warning:
Method returns an Objective-C object with a +1 retain count (owning reference)
Explicitly releasing or autoreleasing a Core Data entity is usually very very bad, but is that what it is asking me to do here? First it tells me it has a +0 retain count and that is bad, then it tells me it has a +1 which is also bad.
What can I do to ensure that I am either dealing with a Analyzer hiccup or that I release correctly?
Thanks in advance
© Stack Overflow or respective owner