Swift 的 Struct 和 Class
- 官方建议
- Use structures by default.
- Use classes when you need Objective-C interoperability.
- Use classes when you need to control the identity of the data you're modeling.
- Use structures along with protocols to adopt behavior by sharing implementations.
- 总结
struct更偏向c的概念,class更偏向java

浙公网安备 33010602011771号