Filters

Hide filters
Platform
Content Type
Difficulty

All Tutorials · 18 Results

Contained in: macOS Apprentice swift
iOS & Swift

Chapter in macOS Apprentice

Beginning Swift

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

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

Swift Playground to learn how to combine Swift types and functions into your own custom types…
iOS & Swift
macOS Apprentice
…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

…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

…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

…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

…right folder. Now, right-click and choose New File from Template… — yet another way to add a file. 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

Data Flow in SwiftUI

…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

Introduction

…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

Building the User Interface

…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

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

…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

Creating the Edit Interface

…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…
iOS & Swift

Chapter in macOS Apprentice

Using Cocoa Bindings

…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

Using AppKit in SwiftUI

Start by making a new file. Select Views in the Project navigator to position the new file. Press Command-N and add a macOS ▸ Swift File called WebView.swift. Replace the file contents with: // 1 import SwiftUI import WebKit // 2 struct WebView: NSViewRepresentable { // 3 let word: String } Stepping through this: Import…
iOS & Swift

Chapter in macOS Apprentice

Getting Data Into Your App

…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

What You Need

…running macOS Sequoia (macOS 15.2) or later. Xcode 16.2 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…