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

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.

主站蜘蛛池模板: 溧阳市| 石泉县| 调兵山市| 大厂| 肇州县| 临武县| 石屏县| 桂阳县| 宜黄县| 法库县| 潢川县| 昭觉县| 莱州市| 九江县| 无极县| 清涧县| 凉城县| 鹰潭市| 普陀区| 辽阳市| 枣庄市| 高青县| 扶余县| 金坛市| 遂平县| 广南县| 子洲县| 双牌县| 五河县| 福建省| 江华| 岑巩县| 镇江市| 项城市| 新民市| 思南县| 行唐县| 沈阳市| 巢湖市| 常德市| 于田县|