Static Analyzer says I have a leak....why?

Posted by Walter on Stack Overflow See other posts from Stack Overflow or by Walter
Published on 2011-01-11T21:48:56Z Indexed on 2011/01/11 21:53 UTC
Read the original article Hit count: 209

I think this code should be fine but Static Analyzer doesn't like it. I can't figure out why and was hoping that someone could help me understand. The code works fine, the analyzer result just bugs me.

Coin *tempCoin = [[Coin alloc] initalize];
self.myCoin = tempCoin;
[tempCoin release];

Coin is a generic NSObject and it has an initalize method. myCoin is a property of the current view and is of type Coin. I assume it is telling me I am leaking tempCoin.

In my view's .h I have set myCoin as a property with nonatomic,retain.

I've tried to autorelease the code as well as this normal release but Static Analyzer continues to say:
1. Method returns an Objective-C object with a +1 retain count (owning reference)
2. Object allocated on line 97 is no longer referenced after this point and has a retain count of +1 (object leaked)

Line 97 is the first line that I show.

© Stack Overflow or respective owner

Related posts about iphone

Related posts about memory-leaks