Strange memory leak with analyze on text setting of UILabel
When I Product > Analyze
the clang analyzer gives me a memory leak I do not understand. It says that I am leaking in the second line something what was initialized in the first line of the following code
[[testView newScore] setText: [NSString stringWithFormat: @"+%d", addScore]];
[[testView newScore] setTextColor: [UIColor greenColor]];
As Instruments isn't working right now (I am using Xcode 4.1 with SDK 4.3) I can't investigate this leak any further.
Do you see why this could be a memory开发者_高级运维 leak. The property newScore
is defined like this:
@property (nonatomic, retain) UILabel *newScore;
and testView
is a subclass of UIView
.
Edit: Screenshot of the analyzer output:
Thank you for reading!
Can you post a screenshot of the analyzer output (i.e. the blue arrows pointing to the problematic control flow)?
Derp; I missed the obvious. Sorry. The method is named newScore
and the new*
prefix indicates to the compiler that the object returned is +1 retain count.
Rename the method and all will be well.
精彩评论