What is the logic behind having a mutable and immutable versions of classes like NSArray, NSDictionary etc in Objective C?

前端 未结 5 1134
半阙折子戏
半阙折子戏 2021-02-12 13:11

Why do common collection classes in Objective C like NSString, NSArray, NSDictionary etc have a mutable as well as an immutable version. What is the logic behind defining them s

5条回答
  •  别跟我提以往
    2021-02-12 13:29

    Apart from the answers mentioned above one difference is : Immutable objects are generally thread safe. Whereas, a Mutable objects are not thread safe.

    thanks

提交回复
热议问题