Swift 的 Struct 和 Class

  • 官方建议
  1. Use structures by default.
  2. Use classes when you need Objective-C interoperability.
  3. Use classes when you need to control the identity of the data you're modeling.
  4. Use structures along with protocols to adopt behavior by sharing implementations.
  • 总结

struct更偏向c的概念,class更偏向java

posted @ 2020-09-13 16:23  fuzheng1998  阅读(86)  评论(0)    收藏  举报