…reverse of the last chapter, add SwiftUI elements into an AppKit app. When is this the right way to build…
iOS & Swift
Chapter in macOS Apprentice
Using AppKit in SwiftUI
Mar 5 2025 · Chapter
SwiftUI can't do everything, so you'll learn how to integrate AppKit features into a SwiftUI app and when this is a good approach…
iOS & Swift
Chapter in macOS Apprentice
Beginning SwiftUI
Mar 5 2025 · Chapter
Start building a full app using SwiftUI. Design and implement the layout using SwiftUI components…
iOS & Swift
Chapter in macOS Apprentice
Data Flow in SwiftUI
Mar 5 2025 · Chapter
Learn more about data flow in SwiftUI and how to send data to all parts of your app. Make an observable object that's available to all your views…
iOS & Swift
Chapter in macOS Apprentice
Introducing Xcode
Mar 5 2025 · Chapter
Bundle Identifier changes to your-org-id.MyFirst. When you submit your app to the App Store, this bundle identifier uniquely identifies your app. For Interface, select SwiftUI. For Language, select Swift. For Testing System and Storage, select None. ➤ Click Next. Here’s where you decide where to save your new project. Decide…
iOS & Swift
Chapter in macOS Apprentice
Getting Data Into Your App
Mar 5 2025 · Chapter
Start adding real data to the user interface. Learn about SwiftUI data flow and property wrappers…
iOS & Swift
Chapter in macOS Apprentice
Showing Other Windows
Mar 5 2025 · Chapter
…create a Settings window to allow users to configure the app. After that, you’ll create an entirely new window with a different SwiftUI view. And you’ll see how to pass data around between different windows. Creating a Settings View Launch Xcode and open the project you ended with…
iOS & Swift
Chapter in macOS Apprentice
Adding Toolbars & Menus
Mar 5 2025 · Chapter
…doesn’t do anything yet, but it’s there. Before making it work, there are a couple of options to set. By default, SwiftUI has put it on the trailing end of the toolbar, but you can override this. Replace the ToolbarItem line with: ToolbarItem(placement: .navigation…
iOS & Swift
Chapter in macOS Apprentice
Beginning AppKit
Mar 5 2025 · Chapter
…previous two sections, you learned some basic Swift and built a complete app using SwiftUI. Apple provides two different layout frameworks for building macOS apps and in this section, you’ll use the other one: AppKit. This chapter starts the process of building an app to list movies from IMDb…
iOS & Swift
Chapter in macOS Apprentice
Charting Your Progress
Mar 5 2025 · Chapter
SwiftUI Charts library to display your game statistics in a more interesting format…
iOS & Swift
macOS Apprentice
Mar 5 2025 · Book
…macOS Apprentice is a series of multi-chapter tutorials where you’ll learn about developing native macOS apps in Swift, using both SwiftUI — Apple’s newest user interface technology — and AppKit — the venerable UI framework. Along the way, you’ll learn several ways to execute Swift code…
iOS & Swift
Chapter in macOS Apprentice
Introduction
Mar 5 2025 · Chapter
…basics of programming in Swift. Along the way, you’ll learn several different ways to execute Swift code. Section II: Building With SwiftUI In this section, you’ll use Apple’s newest user interface technology — SwiftUI — to develop a word-guessing game called Snowman. You’ll learn about data flow…
iOS & Swift
Chapter in macOS Apprentice
Enhancing Your App
Mar 5 2025 · Chapter
…menu doesn’t show any useful help, but it’s good to have it there for searching the other menus. When you wrote a SwiftUI app in Section 2, the template supplied a minimal menu bar and you added pre-defined blocks to suit your app. For an AppKit…
iOS & Swift
Chapter in macOS Apprentice
Using Cocoa Bindings
Mar 5 2025 · Chapter
…manually inserted the matching properties into each one. This time, you’ll do it a different way; you’ll use Cocoa Bindings. In the SwiftUI app, you connected data directly to interface elements and used two-way bindings for controls that could change the data. Cocoa Bindings is an older…
iOS & Swift
Chapter in macOS Apprentice
Running Swift in a Playground
Mar 5 2025 · Chapter
…need the properties to be more mutable, then switch to a class. In Section 2 of this book, you’ll build an app using SwiftUI. SwiftUI has definite rules about using classes in some cases. A common pattern is to have a main data class that contains an array…
iOS & Swift
Chapter in macOS Apprentice
Building the User Interface
Mar 5 2025 · Chapter
…image depending on the value of isFav, and you want to use a colored image from SF Symbols, which is easy in SwiftUI but not quite so straightforward in AppKit. Add this code to the end of showSelectedMovie(_:): // 1 let imageName = movie.isFav ? "heart.fill" : "heart" // 2 let color = movie.isFav ? NSColor.red : NSColor.gray…