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

前端 未结 5 841
感情败类
感情败类 2021-02-12 13:03

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:21

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

    thanks

提交回复
热议问题