开发者

Constant NSString release

NSString *string = @"hello";

1) I keep reading that constant NSString does not get released, but this Apple page mentions:

the compiler makes such object constants unique on a per-module basis, and they’re never deallocated, though you can retain and release them as you do any other object.

http://developer.apple.com/mac/library/documentation/cocoa/conceptual/strings/Articles/CreatingStrings.html

2) If constant NSString does not get released, would it cause memory problems if used extensively? For example, is this a problem if repeated t开发者_JS百科housands of times:

NSString *string = @"One";
...
string = @"two";
...
string = @"three";
...

what's a good alternative?


Constant strings are part of you app's binary.

So, you do not need to worry about memory management, as they exist through all the execution and can not be released.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜