-(void)processGlyph:(int)glyphOne withGlyph:(int)glyphTwo
{
answer = glyphOne + glyphTwo;
NSString *tempText = [[NSString alloc] init];
tempText = [NSString stringWithFormat:@"%i",answer];
[self dispatchText:tempText];
[tempText release];
}
-(void)checkReadyToProcess
{
if (count >= 2) {
[self processGlyph:firstGlyph withGlyph:secondGlyph];
}
}
-(void)dispatchText:(NSString *) theText
{
answerText.text = theText;
}
-(void)processGlyph:(int)glyphOne withGlyph:(int)glyphTwo { answer = glyphOne + glyphTwo; NSString *tempText = [[NSString alloc] init];
Share
Yes. It is here:
You are allocating an
NSString, replacing the variable with an autoreleasedNSString, and then releasing the autoreleasedNSString. This will lead to a memory leak (from the originalNSString) and a crash from over-releasing.Instead, just do:
You don’t have to release it.