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)。 –