Chapter 15

Building Classes, Structures, and Enumerations

In This Chapter

arrow Exploring a simple class, structure, or enumeration in Locatapp

arrow Declaring methods and functions

arrow Considering modifiers

Swift classes are very much like classes in other object-oriented languages. However, in Swift, classes aren’t the only elements that exhibit so-called class behaviors. This is one of the things that makes Swift different from those other languages. Swift’s structures and enumerations, for example, can contain properties and methods, just as classes do. This means that when you’re structuring a Swift app, you may need to revisit some of your decisions about what should constitute the class objects. Sometimes a structure or enumeration may be more appropriate.

This chapter shows you the basics of how to build classes, structures, and enumerations. I’ve combined these together because they have more in common in Swift than they do in many other object-oriented languages.

Exploring Classes, Structures, and Enumerations

You've already seen a number of examples of classes, structures, and enumerations, but the emphasis has been on how you use them in specific parts of Locatapp and other templates. ...

Get Swift For Dummies 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.