Building Lightweight Structures
If we want to get away from object-oriented programming and try something different, we have to free ourselves of classes. In the next few sections, we’ll do just that, and see that we’re not losing anything in the transition.
To make a clean start, close this playground and create a new playground called StructsPlayground.
Let’s think about the IOSDevice that we created as a class: it had some simple properties for the device name and dimensions, and some methods that operated on those properties. If it mostly serves as a container for data, if we don’t care about inheritance, and if the data is small and not difficult to copy around in memory, then it’s the kind of thing that functional programmers would tell ...
Get iOS 10 SDK Development, 1st Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.