What is the purpose of having both NSMutableString and NSString?

前端 未结 4 1752
不知归路
不知归路 2020-12-09 23:45

Why does Objective C provide both class NSString and subclass NSMutableString rather than just provide NSMutableString? Isn\'t a NSString equivalent to \"const NSMutableStr

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-10 00:15

    I think the usage of an immutable string is a hint for the compiler which can perform optimizations by knowning it won't change.

提交回复
热议问题