Category: SwiftUI

  • SwiftUI Data Persistence using AppStorage and SceneStorage

    It is a common requirement for an app to need to store small amounts of data which will persist through app restarts. This is particularly useful for storing user preference settings, or when restoring a scene to the exact state it was in last time it was accessed by the user. SwiftUI provides two property…

  • SwiftUI Observable and Environment Objects – A Tutorial

    The chapter entitled SwiftUI State Properties, Observable, State and Environment Objects introduced the concept of observable and environment objects and explained how these are used to implement a data-driven approach to app development in SwiftUI. This chapter will build on the knowledge from the earlier chapter by creating a simple example project that uses both…

  • SwiftUI Concurrency and Lifecycle Event Modifiers

    One of the key strengths of SwiftUI is that, through the use of features such as views, state properties, and observable objects, much of the work required in making sure an app handles lifecycle changes correctly is performed automatically. It is still often necessary, however, to perform additional actions when certain lifecycle events occur. An…

  • An Introduction to Swift Actors

    Structured concurrency in Swift provides a powerful platform for performing multiple tasks at the same time, greatly increasing app performance and responsiveness. One of the downsides of concurrency is that it can lead to problems when multiple tasks access the same data concurrently, and that access includes a mix of reading and writing operations. This…

  • An Overview of Swift Structured Concurrency

    Concurrency can be defined as the ability of software to perform multiple tasks in parallel. Many app development projects will need to make use of concurrent processing at some point and concurrency is essential for providing a good user experience. Concurrency, for example, is what allows the user interface of an app to remain responsive…

  • An iOS 17 SwiftUI Example Tutorial

    Now that some of the fundamentals of SwiftUI development have been covered, this chapter will begin to put this theory into practice by building an example SwiftUI-based project. This chapter aims to demonstrate using Xcode to design a simple interactive user interface using views, modifiers, state variables, and some basic animation effects. This tutorial will…

  • SwiftUI State Properties, Observable, State and Environment Objects

    Earlier chapters have described how SwiftUI emphasizes a data-driven approach to app development whereby the views in the user interface are updated in response to changes in the underlying data without the need to write handling code. This approach is achieved by establishing a publisher and subscriber relationship between the data and the views in…

  • SwiftUI Stacks and Frames

    User interface design is largely a matter of selecting the appropriate interface components, deciding how those views will be positioned on the screen, and then implementing navigation between the different screens and views of the app. As is to be expected, SwiftUI includes a wide range of user interface components to be used when developing…

  • Creating Custom Views with SwiftUI

    A key step in learning to develop apps using SwiftUI is learning how to declare user interface layouts by using the built-in SwiftUI views and building your own custom views. This chapter will introduce the basic concepts of SwiftUI views and outline the syntax used to declare user interface layouts and modify view appearance and…

  • The Anatomy of a Basic SwiftUI Project

    When a new SwiftUI project is created in Xcode using the Multiplatform App template, Xcode generates a collection of files and folders that form the basis of the project and on which the finished app will eventually be built. Although it is not necessary to know in detail about the purpose of each of these…