0
我是新的Objective-C编程。我正在阅读约NSSting
和NSMutableString
。 NSString
基本上是不可变的字符串,而NSMutableString
是可变的,因为它的名字暗示。这很好但是我想知道除了可变和不可变之外,为什么NSString
还不推荐使用,如果我可以使用NSMutableString
执行NSString
的所有操作。任何人都可以向我清楚?为什么NSString仍然存在,如果我可以做任何事情与NSMutableString?
我相信你的问题已经回答检查[this](http://stackoverflow.com/questions/16460779/what-is-actual-difference-between-nsstring-and-nsmutable-string-in-objective -cw)&[this](http://stackoverflow.com/questions/1749571/what-is-the-purpose-of-having-both-nsmutablestring-and-nsstring) –
感谢@MahbubAhmed和@gema的回应。这真的很有帮助。所以请让我改正,基本上我明白'NSString'的性能(从编译器的角度来看,它消除了额外的值检查和开销条件)和内存方面的'NSString'总是在新分配值上创建新的存储器[link]( http://stackoverflow.com/questions/1749571/what-is-the-purpose-of-having-both-nsmutablestring-and-nsstring)。 –