Static Analyzer says I have a leak....why?
- by Walter
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.