0

I am using Cocos2d 2.0 with ARC and that's my code:

hudAndPlayerFileName = @"hud";        
//...other code
hudAndPlayerFileName = [hudAndPlayerFileName stringByAppendingString:@"ST"];

I am wondering whether appending a string to another string will cause any memory leak or if, ARC, will deal with this. Is there anything in this code that may lead to leaks?

4

1 回答 1

2

您使用字符串常量@"hud"作为输入,返回值是一个自动释放的实例。

hudAndPlayerFileName可以使用NSMutableString.

[hudAndPlayerFileName appendString:@"ST"];

这将在包含的字符串末尾附加“ST”hudAndPlayerFileName

于 2013-05-01T10:41:47.337 回答