Start finding your way around Swift by running it in Terminal. Learn about Swift's data types, operators, variables, constants and collections…
iOS & Swift
Chapter in macOS Apprentice
Using Swift in the Command Line
Apr 24 2026 · Chapter
Xcode to build a command line app that runs in Terminal. Learn more Swift features including conditionals, loops, functions and optionals…
iOS & Swift
Chapter in macOS Apprentice
Running Swift in a Playground
Apr 24 2026 · Chapter
Swift Playground to learn how to combine Swift types and functions into your own custom types…
iOS & Swift
New
macOS Apprentice
Apr 24 2026 · 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
Introducing Xcode
Apr 24 2026 · Chapter
…slows you down when you dive into this book. Install Xcode and create a new project to take a quick tour of Xcode and Swift basics. You'll learn some tips for using Xcode efficiently…
iOS & Swift
Chapter in macOS Apprentice
Powering Up Your Table
Apr 24 2026 · Chapter
…moviesTableView.sortDescriptors) as? [Movie] { // 3 visibleMovies = sortedMovies // 4 moviesTableView.reloadData() } How does this work? In order to sort using the table’s sort descriptors, convert the Swift Array into an Objective-C NSArray. Objective-C was Apple’s language before Swift and a lot of the older frameworks still…
iOS & Swift
Chapter in macOS Apprentice
Beginning AppKit
Apr 24 2026 · 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
Apr 24 2026 · Chapter
…ensure that your new file is in the right folder. Now, right-click and choose New File from Template…. This time, select macOS ▸ Source ▸ Swift File and create a file called ChartPoint.swift. Add this to your new file: // 1 struct ChartPoint: Identifiable { // 2 let id = UUID() // 3 let name: String…
iOS & Swift
Chapter in macOS Apprentice
Introduction
Apr 24 2026 · Chapter
…game you’d like to create. But how do you get started? If you’re an Apple user, you begin by learning the Swift language. There are a lot of resources for this and they nearly all assume that you want to write apps for an iPhone. But the main…
iOS & Swift
Chapter in macOS Apprentice
Data Flow in SwiftUI
Apr 24 2026 · Chapter
…swap between them. Select the Models folder in the Project navigator and press Command-N to make a new file. Choose macOS ▸ Source ▸ Swift File and name it AppState.swift. Your previous models have been structures or enumerations, but this one has to be a class. When you learned about classes…
iOS & Swift
Chapter in macOS Apprentice
Building the User Interface
Apr 24 2026 · Chapter
…previous chapter, you loaded in the movies.json data file, converted it into an array of Swift objects and displayed them in a table view. It’s a common pattern in Mac apps to have a list of items on the left and a details pane on the right, showing more…
iOS & Swift
Chapter in macOS Apprentice
Beginning SwiftUI
Apr 24 2026 · Chapter
Section 1, you installed Xcode and used various tools to run Swift code on your Mac. In this section, you’ll apply that knowledge to create an entire app for your Mac using Swift and SwiftUI. Chapter 1 gave a tour of Xcode, explained the basic structure…
iOS & Swift
Chapter in macOS Apprentice
Showing Other Windows
Apr 24 2026 · Chapter
…true, return true to include all the remaining words. Get the first letter of the word. This isn’t a simple process in Swift. Many languages allow you to use word[0] to get the first character, but Swift strings are fully Unicode compliant. This means that a single visible…
iOS & Swift
Chapter in macOS Apprentice
Using Cocoa Bindings
Apr 24 2026 · Chapter
…data seems to appear by magic, and it can take a lot of detective work to track down exactly what’s happening. Source control: Swift files are plain text and, when you use a source control system like git, you can track all the edits and revert any changes…
iOS & Swift
Chapter in macOS Apprentice
What You Need
Apr 24 2026 · Chapter
…running macOS Tahoe (macOS 26) or later. Xcode 26 or later. Xcode is the main development environment for building macOS Apps. It includes the Swift compiler, the debugger and other development tools you’ll need. You can download the latest version of Xcode for free from the Mac App Store…
iOS & Swift
Chapter in macOS Apprentice
Getting Data Into Your App
Apr 24 2026 · Chapter
…mutable properties. @Binding sends data to a view and allows that view to send any changes back. You can include data files in your Swift apps and read them from the app bundle. Where to Go From Here? Your game now works perfectly, but the sidebar is still showing…
iOS & Swift
Chapter in macOS Apprentice
Creating the Edit Interface
Apr 24 2026 · Chapter
…user interface. You’ll use Main.storyboard for the design, so you don’t need a separate design file. Make sure Language is set to Swift and press Next, then Create: Adding a view controller. This gives your project a new NSViewController class…