开发者

Constant NSString release

开发者 https://www.devze.com 2023-01-14 17:46 出处:网络
NSString *string = @\"hello\"; 1) I keep reading that constant NSString does not get released, but this Apple page mentions:
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

精彩评论

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