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

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.

主站蜘蛛池模板: 商水县| 沙洋县| 宝应县| 赤城县| 全椒县| 大英县| 房产| 定南县| 玉溪市| 成安县| 静安区| 丰镇市| 墨江| 肇源县| 应城市| 漳浦县| 平潭县| 南丰县| 绵竹市| 疏附县| 米林县| 平远县| 雅安市| 洪泽县| 吴忠市| 蓬溪县| 西宁市| 张家界市| 泗阳县| 格尔木市| 宜都市| 浦东新区| 阿克苏市| 孝昌县| 河北省| 丰顺县| 普安县| 津南区| 鄢陵县| 崇信县| 乾安县|