官术网_书友最值得收藏!

Structs

Objects are great for encapsulating data and functionality behind a unifying and referenceable concept, such as a person. However, not everything is an object; we may have a set of data that is logically grouped together, but that isn't much more than that. It's not more than the sum of its parts--it is the sum of its parts.

For this, there are structs. Short for structure, structs can be found in the C programming language and were, therefore, available in Objective-C, which was built on top of C. If you are familiar with iOS/macOS development, CGRect is an example of a C struct.

Structs are value types, as opposed to classes, which are reference types, and as such behave differently when passed around. In this recipe, we will examine how structs work in Swift, and learn when and how to use them.

主站蜘蛛池模板: 洪雅县| 普兰店市| 大庆市| 乌苏市| 建阳市| 晋江市| 油尖旺区| 茂名市| 宁南县| 安仁县| 察哈| 南阳市| 珠海市| 互助| 东海县| 建平县| 高密市| 阿拉尔市| 公主岭市| 西峡县| 邻水| 册亨县| 乌鲁木齐县| 如皋市| 万安县| 扶沟县| 桃江县| 奈曼旗| 交口县| 定襄县| 法库县| 视频| 黔西| 金昌市| 特克斯县| 丽江市| 防城港市| 贵港市| 泰州市| 师宗县| 广州市|