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

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.

主站蜘蛛池模板: 天门市| 偃师市| 淮滨县| 鱼台县| 泽普县| 定日县| 鄂伦春自治旗| 紫云| 青田县| 扎赉特旗| 长春市| 吴川市| 通许县| 明光市| 安远县| 阜南县| 泾阳县| 信宜市| 西林县| 芜湖市| 奎屯市| 临漳县| 城固县| 丹巴县| 吉林市| 宁海县| 张家口市| 邯郸市| 巴南区| 历史| 大关县| 闽清县| 天水市| 开鲁县| 新晃| 阳西县| 北票市| 东台市| 获嘉县| 古浪县| 孝昌县|