In order to set cell.textLabel.text in the cellForRowAtIndexPath method I alloc and init a string. If I release this string after setting cell.textLabel.text, then the program will crash after doing this several times.
Why doesn't it crash the first time? Since the string was alloced and inited, doesn't it have to be released?
Here's the code:
NSString *cellText = [[NSString alloc] init];
cellText = [NSString stringWithFormat:@"(%.1f points", totalpoints];
if (showNumberOfPlayers) {
cellText = [cellText stringByAppendingFormat:@", %i players) ", [[playerArray objectAtIndex:indexPath.row] count]];
}
else {
cellText = [cellText stringByAppendingString:@") "];
}
cell.textLabel.text = [cellText stringByAppendingString:teamList];
[cellText release];