Category: SwiftUI

  • An Overview of SwiftUI

    Now that Xcode has been installed and the basics of the Swift programming language are covered, it is time to start introducing SwiftUI. First announced at Apple’s Worldwide Developer Conference in 2019, SwiftUI is an entirely new approach to developing apps for all Apple operating system platforms. The primary goals of SwiftUI are to make…

  • Understanding Error Handling in Swift

    In a perfect world, a running iOS app would never encounter an error. The reality, however, is that it is impossible to guarantee that an error of some form or another will not occur at some point during the execution of the app. It is essential, therefore, to ensure that the code of an app…

  • Working with Array and Dictionary Collections in Swift

    Arrays and dictionaries in Swift are objects that contain collections of other objects. This chapter will cover some of the basics of working with arrays and dictionaries in Swift. Mutable and Immutable Collections Collections in Swift come in mutable and immutable forms. The contents of immutable collection instances cannot be changed after the object has…

  • An Introduction to Swift Property Wrappers

    Now that the topics of Swift classes and structures have been covered, this chapter will introduce a related topic in the form of property wrappers. Introduced in Swift 5.1, property wrappers provide a way to reduce the amount of duplicated code involved in writing getters, setters and computed properties in class and structure implementations. Understanding…

  • An Introduction to Swift Structures and Enumerations

    Having covered Swift classes in the preceding chapters, this chapter will introduce the use of structures in Swift. Although at first glance structures and classes look similar, there are some important differences that need to be understood when deciding which to use. This chapter will outline how to declare and use structures, explore the differences…

  • An Introduction to Swift Subclassing and Extensions

    In The Basics of Swift Object-Oriented Programming, we covered the basic concepts of object-oriented programming and worked through an example of creating and working with a new class using Swift. In that example, our new class was not derived from any base class and, as such, did not inherit any traits from a parent or…

  • The Basics of Swift Object-Oriented Programming

    Swift provides extensive support for developing object-oriented applications. The subject area of object-oriented programming is, however, large. It is not an exaggeration to state that entire books have been dedicated to the subject. As such, a detailed overview of object-oriented software development is beyond the scope of this book. Instead, we will introduce the basic…

  • Swift Functions, Methods, and Closures

    Swift functions, methods, and closures are a vital part of writing well-structured and efficient code and provide a way to organize programs while avoiding code repetition. This chapter will look at how functions, methods, and closures are declared and used within Swift. What is a Function? A function is a named block of code that…

  • The Swift Switch Statement

    In Swift Control Flow, we looked at controlling program execution flow using the if and else statements. While these statement constructs work well for testing a limited number of conditions, they quickly become unwieldy when dealing with larger numbers of possible conditions. To simplify such situations, Swift has inherited the switch statement from the C…

  • Swift Control Flow

    Regardless of the programming language used, application development is largely an exercise in applying logic, and much of the art of programming involves writing code that makes decisions based on one or more criteria. Such decisions define which code gets executed, how many times it is executed and, conversely, which code gets by-passed when the…