我在自动释放池中进行了大量的NSString操作。问题是我的程序有时会在游泳池流失之前崩溃。我想知道是否有办法通过将nil分配给NSString来规避这个问题。对userLetters的分配发生了很多。见下面将自动释放池中的NSString指定为NSString
代码之前
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
usersLetters = [usersLetters stringByReplacingCharactersInRange:NSMakeRange(indexUser, 1) withString:@"*"];
[pool drain];
后
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
NSString *temp = [usersLetters stringByReplacingCharactersInRange:NSMakeRange(indexUser, 1) withString:@"*"]; //remove that found character so it can't be reused again
usersLetters = nil;
usersLetters = temp;
temp = nil;
[pool drain];