I’m getting some unusual responses from the Produce > Analyze option in Xcode 4 that don’t seem to make any sense to me. For example, I’ve always been taught to release instance variables in the dealloc method, but Analyze gives me this:
- (void)dealloc {
[self.fileName release];
//Incorrect decrement of the reference count of an object that is not owned at this point by the caller
Very confusing, can anyone shed some light on this one?
The property looks like this:
@property (nonatomic, retain) NSString * fileName;
Confusing wording, but correct, error message.
When you do:
That can easily produce a dangling reference for the instance variable backing the
fooproperty. I.e. as far as the compiler is concerned, there is noretainthat saidreleaseis balancing.Either do:
(Assuming
@synthesize foo = fooIVar;)Or: