As NSString
字符串是不可变的,它的值是多少stringWithString:
类方法?
与使用时我得到了实用程序NSMutableString
,我只是没有看到实用程序NSString
class.
您可能有一个想要复制的 NSMutableString (或一些本地开发的 NSString 子类)。
NSMutableString *buffer = [NSMutableString string];
// do something with buffer
NSString *immutableStringToKeepAround = [NSString stringWithString:buffer];
当然,你也可以直接复制一份:
NSMutableString *buffer = [NSMutableString string];
// do something with buffer
NSString *immutableStringToKeepAround = [[buffer copy] autorelease];
但您拥有该副本并且必须释放或自动释放它。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)