why string, array and dictionary in Swift changed to value type

前端 未结 4 525
伪装坚强ぢ
伪装坚强ぢ 2021-02-02 11:54

In Objc string, array and dictionary are all reference types, while in Swift they are all value types.

  1. I want to figure out what\'s the reason behind the scenes

4条回答
  •  醉酒成梦
    2021-02-02 12:25

    In addition to the previous answers, there are also multi-threading issues to consider with sharing a Reference-Based collection type that we don't have to worry as much with sharing an instance of a type that is Value-Based and has Copy-On-Write behavior. Multi-core is becoming more and more proliferant even on iOS devices, so it has become more of an issue for the Swift language developers to consider.

提交回复
热议问题