Slide 1

Slide 1 text

DUB DUB TIME MACHINE (aka, what's new for n-2 supporting apps) SwiftConnection | Paris | September 2024 Ellen Shapiro | mastodon.social/@designatednerd | pixiteapps.com

Slide 2

Slide 2 text

WWDC

Slide 3

Slide 3 text

WWDC

Slide 4

Slide 4 text

Your Job

Slide 5

Slide 5 text

Your Job

Slide 6

Slide 6 text

N - 2

Slide 7

Slide 7 text

Why can't we upgrade?!

Slide 8

Slide 8 text

Existing customer stats

Slide 9

Slide 9 text

Losing new customers on old OS versions

Slide 10

Slide 10 text

! ♻

Slide 11

Slide 11 text

No content

Slide 12

Slide 12 text

No content

Slide 13

Slide 13 text

No content

Slide 14

Slide 14 text

No content

Slide 15

Slide 15 text

No content

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

No content

Slide 18

Slide 18 text

iOS 16!

Slide 19

Slide 19 text

SwiftUI

Slide 20

Slide 20 text

NavigationView

Slide 21

Slide 21 text

Navigation View

Slide 22

Slide 22 text

NavigationStack NavigationSplitView

Slide 23

Slide 23 text

Better Programmatic Navigation

Slide 24

Slide 24 text

Navigation Stack

Slide 25

Slide 25 text

enum Route: Hashable { case login case signup case home case profile } class NavigationModel: ObservableObject { @Published var navigationPath = [Route]() func handleDeeplinkToProfile() { self.navigationPath = [.home, .profile] } }

Slide 26

Slide 26 text

enum Route: Hashable { case login case signup case home case profile } class NavigationModel: ObservableObject { @Published var navigationPath = [Route]() }

Slide 27

Slide 27 text

struct ContentView: View { @StateObject var navigationModel: NavigationModel var body: some View { NavigationStack(path: self.$navigationModel.navigationPath) { VStack(spacing: 20) { NavigationLink(value: Route.login) { Text("Login") } /" ..$ } .navigationDestination(for: Route.self) { route in switch route { case .login: return TitleView(title: "I am the login page!", navigationModel: self.navigationModel) /" ..$ } } } } }

Slide 28

Slide 28 text

struct ContentView: View { @StateObject var navigationModel: NavigationModel var body: some View { NavigationStack(path: self.$navigationModel.navigationPath) { VStack(spacing: 20) { NavigationLink(value: Route.login) { Text("Login") } /" ..$ } .navigationDestination(for: Route.self) { route in switch route { case .login: return TitleView(title: "I am the login page!", navigationModel: self.navigationModel) /" ..$ } } } }

Slide 29

Slide 29 text

struct ContentView: View { @StateObject var navigationModel: NavigationModel var body: some View { NavigationStack(path: self.$navigationModel.navigationPath) { VStack(spacing: 20) { NavigationLink(value: Route.login) { Text("Login") } /" ..$ } .navigationDestination(for: Route.self) { route in switch route { case .login: return TitleView(title: "I am the login page!", navigationModel: self.navigationModel) /" ..$ } } } }

Slide 30

Slide 30 text

struct ContentView: View { @StateObject var navigationModel: NavigationModel var body: some View { NavigationStack(path: self.$navigationModel.navigationPath) { VStack(spacing: 20) { NavigationLink(value: Route.login) { Text("Login") } /" ..$ } .navigationDestination(for: Route.self) { route in switch route { case .login: return TitleView(title: "I am the login page!", navigationModel: self.navigationModel) /" ..$ } } } }

Slide 31

Slide 31 text

No content

Slide 32

Slide 32 text

struct ContentView: View { @StateObject var navigationModel: NavigationModel var body: some View { NavigationStack(path: self.$navigationModel.navigationPath) { VStack(spacing: 20) { /" ..$ Button { self.navigationModel.navigationPath = [.home, .profile] } label: { Text("Deeplink to profile") } } .navigationDestination(for: Route.self) { route in switch route { /" ..$ case .home: return TitleView(title: "I am the home page!", navigationModel: self.navigationModel) case .profile: return TitleView(title: "I am the profile page!", navigationModel: self.navigationModel) } } } }

Slide 33

Slide 33 text

struct ContentView: View { @StateObject var navigationModel: NavigationModel var body: some View { NavigationStack(path: self.$navigationModel.navigationPath) { VStack(spacing: 20) { /" ..$ Button { self.navigationModel.navigationPath = [.home, .profile] } label: { Text("Deeplink to profile") } } .navigationDestination(for: Route.self) { route in switch route { /" ..$ case .home: return TitleView(title: "I am the home page!", navigationModel: self.navigationModel) case .profile: return TitleView(title: "I am the profile page!", navigationModel: self.navigationModel) } } } }

Slide 34

Slide 34 text

struct ContentView: View { @StateObject var navigationModel: NavigationModel var body: some View { NavigationStack(path: self.$navigationModel.navigationPath) { VStack(spacing: 20) { /" ..$ Button { self.navigationModel.navigationPath = [.home, .profile] } label: { Text("Deeplink to profile") } } .navigationDestination(for: Route.self) { route in switch route { /" ..$ case .home: return TitleView(title: "I am the home page!", navigationModel: self.navigationModel) case .profile: return TitleView(title: "I am the profile page!", navigationModel: self.navigationModel) } } } }

Slide 35

Slide 35 text

No content

Slide 36

Slide 36 text

struct TitleView: View { let title: String let navigationModel: NavigationModel var body: some View { VStack(spacing: 100) { Text(self.title) Button { self.navigationModel.navigationPath = [] } label: { Text("Log out") } } .navigationTitle(self.title) } }

Slide 37

Slide 37 text

struct TitleView: View { let title: String let navigationModel: NavigationModel var body: some View { VStack(spacing: 100) { Text(self.title) Button { self.navigationModel.navigationPath = [] } label: { Text("Log out") } } .navigationTitle(self.title) } }

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

NavigationSplitView

Slide 40

Slide 40 text

No content

Slide 41

Slide 41 text

AnyLayout

Slide 42

Slide 42 text

@Environment(\.horizontalSizeClass) var horizontalSizeClass var body: some View { if self.horizontalSizeClass =" .compact { return VStack { /$..& } } else { return HStack { /$..& } } }

Slide 43

Slide 43 text

No content

Slide 44

Slide 44 text

@Environment(\.horizontalSizeClass) var horizontalSizeClass var body: some View { if self.horizontalSizeClass =" .compact { return AnyView(VStack { /$..& }) } else { return AnyView(HStack { /$..& }) } }

Slide 45

Slide 45 text

No content

Slide 46

Slide 46 text

AnyView -> ☠ Performance

Slide 47

Slide 47 text

AnyLayout -> ! Performance

Slide 48

Slide 48 text

@Environment(\.horizontalSizeClass) var horizontalSizeClass var body: some View { let layout: AnyLayout if self.horizontalSizeClass =" .compact { layout = AnyLayout(VStackLayout()) } else { layout = AnyLayout(HStackLayout()) } return layout { Text("1") Text("2") } }

Slide 49

Slide 49 text

@Environment(\.horizontalSizeClass) var horizontalSizeClass var body: some View { let layout: AnyLayout if self.horizontalSizeClass =" .compact { layout = AnyLayout(VStackLayout()) } else { layout = AnyLayout(HStackLayout()) } return layout { Text("1") Text("2") } }

Slide 50

Slide 50 text

@Environment(\.horizontalSizeClass) var horizontalSizeClass var body: some View { let layout: AnyLayout if self.horizontalSizeClass =" .compact { layout = AnyLayout(VStackLayout()) } else { layout = AnyLayout(HStackLayout()) } return layout { Text("1") Text("2") } }

Slide 51

Slide 51 text

Batteries included: ZStackLayout GridLayout

Slide 52

Slide 52 text

Batteries NOT included: Build your own! (Layout is a public protocol)

Slide 53

Slide 53 text

Making UIKit cells with SwiftUI

Slide 54

Slide 54 text

UIHostingConfiguration

Slide 55

Slide 55 text

let item = items[indexPath.row] cell.contentConfiguration = UIHostingConfiguration { HStack { Text(item.title) Spacer() Image(systemName: "star.fill") .foregroundColor(item.isFavorite ? .yellow : .gray) } }

Slide 56

Slide 56 text

let item = items[indexPath.row] cell.contentConfiguration = UIHostingConfiguration { ItemView(for: item) }

Slide 57

Slide 57 text

! New SwiftUI stuff

Slide 58

Slide 58 text

Swift Charts

Slide 59

Slide 59 text

! vs. " vs.

Slide 60

Slide 60 text

struct HamConsumptionPerWeek { let average: Float let country: String }

Slide 61

Slide 61 text

struct HamConsumptionPerWeek { let average: Float let country: String static let averageTitle = "Times I Eat Ham Per Week" static let countryTitle = "Country I Am In" }

Slide 62

Slide 62 text

private struct BarChart: View { let data: [HamConsumptionPerWeek] var body: some View { Chart(data, id: \.average) { BarMark(x: .value(HamConsumptionPerWeek.countryTitle, $0.country), y: .value(HamConsumptionPerWeek.averageTitle, $0.average), width: .automatic) .foregroundStyle(Color.blue.gradient) } .chartXAxisLabel(HamConsumptionPerWeek.countryTitle, alignment: .center) .chartYAxisLabel(HamConsumptionPerWeek.averageTitle, position: .trailing, alignment: .center) } }

Slide 63

Slide 63 text

private struct BarChart: View { let data: [HamConsumptionPerWeek] var body: some View { Chart(data, id: \.average) { BarMark(x: .value(HamConsumptionPerWeek.countryTitle, $0.country), y: .value(HamConsumptionPerWeek.averageTitle, $0.average), width: .automatic) .foregroundStyle(Color.blue.gradient) } .chartXAxisLabel(HamConsumptionPerWeek.countryTitle, alignment: .center) .chartYAxisLabel(HamConsumptionPerWeek.averageTitle, position: .trailing, alignment: .center) } }

Slide 64

Slide 64 text

private struct BarChart: View { let data: [HamConsumptionPerWeek] var body: some View { Chart(data, id: \.average) { BarMark(x: .value(HamConsumptionPerWeek.countryTitle, $0.country), y: .value(HamConsumptionPerWeek.averageTitle, $0.average), width: .automatic) .foregroundStyle(Color.blue.gradient) } .chartXAxisLabel(HamConsumptionPerWeek.countryTitle, alignment: .center) .chartYAxisLabel(HamConsumptionPerWeek.averageTitle, position: .trailing, alignment: .center) } }

Slide 65

Slide 65 text

private struct BarChart: View { let data: [HamConsumptionPerWeek] var body: some View { Chart(data, id: \.average) { BarMark(x: .value(HamConsumptionPerWeek.countryTitle, $0.country), y: .value(HamConsumptionPerWeek.averageTitle, $0.average), width: .automatic) .foregroundStyle(Color.blue.gradient) } .chartXAxisLabel(HamConsumptionPerWeek.countryTitle, alignment: .center) .chartYAxisLabel(HamConsumptionPerWeek.averageTitle, position: .trailing, alignment: .center) } }

Slide 66

Slide 66 text

No content

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

No content

Slide 69

Slide 69 text

private struct BarChart: View { let data: [HamConsumptionPerWeek] var body: some View { Chart(data, id: \.average) { BarMark(x: .value(HamConsumptionPerWeek.countryTitle, $0.country), y: .value(HamConsumptionPerWeek.averageTitle, $0.average), width: .automatic) .foregroundStyle(Color.blue.gradient) } .chartXAxisLabel(HamConsumptionPerWeek.countryTitle, alignment: .center) .chartYAxisLabel(HamConsumptionPerWeek.averageTitle, position: .trailing, alignment: .center) } }

Slide 70

Slide 70 text

private struct LineChart: View { let data: [HamConsumptionPerWeek] var body: some View { Chart(data, id: \.average) { LineMark(x: .value(HamConsumptionPerWeek.countryTitle, $0.country), y: .value(HamConsumptionPerWeek.averageTitle, $0.average)) .foregroundStyle(Color.blue.gradient) } .chartXAxisLabel(HamConsumptionPerWeek.countryTitle, alignment: .center) .chartYAxisLabel(HamConsumptionPerWeek.averageTitle, position: .trailing, alignment: .center) } }

Slide 71

Slide 71 text

private struct LineChart: View { let data: [HamConsumptionPerWeek] var body: some View { Chart(data, id: \.average) { LineMark(x: .value(HamConsumptionPerWeek.countryTitle, $0.country), y: .value(HamConsumptionPerWeek.averageTitle, $0.average)) .foregroundStyle(Color.blue.gradient) } .chartXAxisLabel(HamConsumptionPerWeek.countryTitle, alignment: .center) .chartYAxisLabel(HamConsumptionPerWeek.averageTitle, position: .trailing, alignment: .center) } }

Slide 72

Slide 72 text

No content

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

https://github.com/jordibruin/ Swift-Charts-Examples

Slide 76

Slide 76 text

Slide 77

Slide 77 text

Source: https://flickr.com/photos/meg-z/5209610108

Slide 78

Slide 78 text

Source: https://flickr.com/photos/meg-z/5209610108

Slide 79

Slide 79 text

Bottom Sheet

Slide 80

Slide 80 text

struct ContentView: View { @State private var showingCredits = false var body: some View { Button("Show Credits") { showingCredits.toggle() } .sheet(isPresented: $showingCredits) { Text("This example was flagrantly stolen from Hacking with Swift") } } } Hi Paul!

Slide 81

Slide 81 text

struct ContentView: View { @State private var showingCredits = false var body: some View { Button("Show Credits") { showingCredits.toggle() } .sheet(isPresented: $showingCredits) { Text("This example was flagrantly stolen from Hacking with Swift") } } } Hi Paul!

Slide 82

Slide 82 text

No content

Slide 83

Slide 83 text

Presentation Detents

Slide 84

Slide 84 text

struct ContentView: View { @State private var showingCredits = false var body: some View { Button("Show Credits") { showingCredits.toggle() } .sheet(isPresented: $showingCredits) { Text("This example was flagrantly stolen from Hacking with Swift") .presentationDetents([.medium, .large]) } } } Hi Paul!

Slide 85

Slide 85 text

No content

Slide 86

Slide 86 text

struct ContentView: View { @State private var showingCredits = false var body: some View { Button("Show Credits") { showingCredits.toggle() } .sheet(isPresented: $showingCredits) { Text("This example was flagrantly stolen from Hacking with Swift") .presentationDetents([.medium, .large]) .presentationDragIndicator(.hidden) } } } Hi Paul!

Slide 87

Slide 87 text

No content

Slide 88

Slide 88 text

Multi-Date Picker

Slide 89

Slide 89 text

struct ContentView: View { @State private var dates: Set = [] var body: some View { MultiDatePicker("Select dates", selection: $dates) .frame(height: 400) .padding() } }

Slide 90

Slide 90 text

struct ContentView: View { @State private var dates: Set = [] var body: some View { MultiDatePicker("Select dates", selection: $dates) .frame(height: 400) .padding() } }

Slide 91

Slide 91 text

No content

Slide 92

Slide 92 text

No content

Slide 93

Slide 93 text

No content

Slide 94

Slide 94 text

No content

Slide 95

Slide 95 text

No content

Slide 96

Slide 96 text

Not SwiftUI

Slide 97

Slide 97 text

TextKit 2

Slide 98

Slide 98 text

TextKit 2 (the bane of my existence)

Slide 99

Slide 99 text

No content

Slide 100

Slide 100 text

No content

Slide 101

Slide 101 text

NSLayoutManager -> NSTextLayoutManager .layoutManager -> .textLayoutManager NSContentStorage -> NSTextContentStorage

Slide 102

Slide 102 text

.layoutManager -> .textLayoutManager

Slide 103

Slide 103 text

/" NSTextContentStorageDelegate public func textContentStorage( _ textContentStorage: NSTextContentStorage, textParagraphWith range: NSRange) -$ NSTextParagraph?

Slide 104

Slide 104 text

/" NSTextLayoutManagerDelegate public func textLayoutManager( _ textLayoutManager: NSTextLayoutManager, textLayoutFragmentFor location: NSTextLocation, in textElement: NSTextElement) -$ NSTextLayoutFragment

Slide 105

Slide 105 text

TK2 Good ‣ Way better separation of display vs storage concerns

Slide 106

Slide 106 text

TK2 Good ‣ Way better separation of display vs storage concerns ‣ Layout fragments to allow more complex and reusable design choices

Slide 107

Slide 107 text

TK2 Good ‣ Way better separation of display vs storage concerns ‣ Layout fragments to allow more complex and reusable design choices ‣ Handling composed character languages and emoji is much easier

Slide 108

Slide 108 text

TK2 Less Good...

Slide 109

Slide 109 text

Existing UITextView bugs

Slide 110

Slide 110 text

UITextRange <-> NSTextRange <-> NSRange <-> Swift.Range

Slide 111

Slide 111 text

Who Uses What ‣ UITextRange/Location: Selection in UITextView

Slide 112

Slide 112 text

Who Uses What ‣ UITextRange/Location: Selection in UITextView ‣ NSTextRange/Location: Fragments, Layout manager, Text Elements, Text content storage delegate

Slide 113

Slide 113 text

Who Uses What ‣ UITextRange/Location: Selection in UITextView ‣ NSTextRange/Location: Fragments, Layout manager, Text Elements, Text content storage delegate ‣ NSRange: Working with ranges of the underlying NSString or NSAttributedString

Slide 114

Slide 114 text

Who Uses What ‣ UITextRange/Location: Selection in UITextView ‣ NSTextRange/Location: Fragments, Layout manager, Text Elements, Text content storage delegate ‣ NSRange: Working with ranges of the underlying NSString or NSAttributedString ‣ Swift.Range: Working with any Swift.String or Swift.AttributedString you wound up with

Slide 115

Slide 115 text

"Make the selected range bold"

Slide 116

Slide 116 text

"Make the selected range bold" ‣ Make sure NSTextStorage for the UITextView is hooked up to NSTextContentStorage's underlying text storage

Slide 117

Slide 117 text

"Make the selected range bold" ‣ Make sure NSTextStorage for the UITextView is hooked up to NSTextContentStorage's underlying text storage ‣ Get UITextRange of selected text from UITextView

Slide 118

Slide 118 text

"Make the selected range bold" ‣ Make sure NSTextStorage for the UITextView is hooked up to NSTextContentStorage's underlying text storage ‣ Get UITextRange of selected text from UITextView ‣ Convert UITextRange to NSRange

Slide 119

Slide 119 text

"Make the selected range bold" ‣ Make sure NSTextStorage for the UITextView is hooked up to NSTextContentStorage's underlying text storage ‣ Get UITextRange of selected text from UITextView ‣ Convert UITextRange to NSRange ‣ Use NSRange to update underlying NSAttributedString in textContentStorage.contentStorage font to a bold one

Slide 120

Slide 120 text

"Make the selected range bold" ‣ Make sure NSTextStorage for the UITextView is hooked up to NSTextContentStorage's underlying text storage ‣ Get UITextRange of selected text from UITextView ‣ Convert UITextRange to NSRange ‣ Use NSRange to update underlying NSAttributedString in textContentStorage.contentStorage font to a bold one ‣ Have layout elements reload using NSTextRange

Slide 121

Slide 121 text

When should you use TextKit 2?

Slide 122

Slide 122 text

Use TK2: ‣ New Apps

Slide 123

Slide 123 text

Use TK2: ‣ New Apps ‣ Apps without super-complicated text logic that interact with TK1

Slide 124

Slide 124 text

Use TK2: ‣ New Apps ‣ Apps without super-complicated text logic that interact with TK1 ‣ Apps with complicated but well-tested text logic

Slide 125

Slide 125 text

Use TK2: ‣ New Apps ‣ Apps without super-complicated text logic that interact with TK1 ‣ Apps with complicated but well-tested text logic ‣ Apps which want deeper interaction with Apple Intelligence™

Slide 126

Slide 126 text

No content

Slide 127

Slide 127 text

Save yourself some trouble! ‣ Existing apps with very complex and untested display and/or storage logic

Slide 128

Slide 128 text

Data Scanner View Controller

Slide 129

Slide 129 text

Before ↔ " # $

Slide 130

Slide 130 text

After ! DataScannerViewController

Slide 131

Slide 131 text

Features ‣ Locations of detected data already in view coordinates

Slide 132

Slide 132 text

Features ‣ Locations of detected data already in view coordinates ‣ Items have unique identifiers

Slide 133

Slide 133 text

Features ‣ Locations of detected data already in view coordinates ‣ Items have unique identifiers ‣ Items are placed in reading order in delegate callbacks

Slide 134

Slide 134 text

Features ‣ Locations of detected data already in view coordinates ‣ Items have unique identifiers ‣ Items are placed in reading order in delegate callbacks ‣ Async stream available if you don't need to create UI.

Slide 135

Slide 135 text

Non-UI features!

Slide 136

Slide 136 text

Transferable Protocol

Slide 137

Slide 137 text

Transferable Protocol* * - Kind of for UI but doesn't provide any itself

Slide 138

Slide 138 text

Drag + Drop Copy + Paste Across apps

Slide 139

Slide 139 text

Generic Transferrables ‣ ProxyRepresentation

Slide 140

Slide 140 text

Generic Transferrables ‣ ProxyRepresentation ‣ CodableRepresentation

Slide 141

Slide 141 text

Generic Transferrables ‣ ProxyRepresentation ‣ CodableRepresentation ‣ DataRepresentation

Slide 142

Slide 142 text

Generic Transferrables ‣ ProxyRepresentation ‣ CodableRepresentation ‣ DataRepresentation ‣ FileRepresentation

Slide 143

Slide 143 text

Matter Orders

Slide 144

Slide 144 text

Order Matters

Slide 145

Slide 145 text

Order Matters

Slide 146

Slide 146 text

Swift Regex

Slide 147

Slide 147 text

Runtime support for parameterized protocol types is only available in iOS 16.0.0 or newer 'Regex' is only available in iOS 16.0 or newer

Slide 148

Slide 148 text

let route = """ I took a plane to Chicago. I took a plane to Barcelona. I took a train to Zaragoza. I took a train to Logroño. I took a train to Zaragoza. I took a train to Barcelona. I took a train to Paris. I took a plane to Washington. I took a plane to Rochester. """

Slide 149

Slide 149 text

Before: NSRegularExpression

Slide 150

Slide 150 text

let travelPattern = "I took a (?[A-z]+) to (?[A-z]+)" if let regex = try? NSRegularExpression(pattern: travelPattern, options: []) { regex.enumerateMatches(in: rtfString, options: [], range: fullRange) { /"..$ } }

Slide 151

Slide 151 text

Regex Literals

Slide 152

Slide 152 text

let travelSearch = /I took a (.+?) to (.+?)\./ let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 153

Slide 153 text

let travelSearch = /I took a (.+?) to (.+?)\./ let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 154

Slide 154 text

let travelSearch = /I took a (.+?) to (.+?)\./ let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 155

Slide 155 text

let travelSearch = /I took a (.+?) to (.+?)\./ let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 156

Slide 156 text

let travelSearch = /I took a (.+?) to (.+?)\./ let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 157

Slide 157 text

No content

Slide 158

Slide 158 text

Regex Builder

Slide 159

Slide 159 text

let travelSearch = /I took a (.+?) to (.+?)\./ let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 160

Slide 160 text

No content

Slide 161

Slide 161 text

let travelSearch = Regex { "I took a " Capture { OneOrMore(.word) } " to " Capture { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 162

Slide 162 text

let travelSearch = Regex { "I took a " Capture { OneOrMore(.word) } " to " Capture { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 163

Slide 163 text

let travelSearch = Regex { "I took a " Capture { OneOrMore(.word) } " to " Capture { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 164

Slide 164 text

let travelSearch = Regex { "I took a " Capture { OneOrMore(.word) } " to " Capture { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 165

Slide 165 text

No content

Slide 166

Slide 166 text

let transportMethod = Reference(Substring.self) let destination = Reference(Substring.self) let travelSearchRB = Regex { "I took a " Capture { OneOrMore(.word) } " to " Capture { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 167

Slide 167 text

let transportMethod = Reference(Substring.self) let destination = Reference(Substring.self) let travelSearchRB = Regex { "I took a " Capture(as: transportMethod) { OneOrMore(.word) } " to " Capture(as: transportMethod) { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 168

Slide 168 text

let transportMethod = Reference(Substring.self) let destination = Reference(Substring.self) let travelSearchRB = Regex { "I took a " Capture(as: transportMethod) { OneOrMore(.word) } " to " Capture(as: transportMethod) { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match.output.1)") print("Destination: \(match.output.2)") }

Slide 169

Slide 169 text

let transportMethod = Reference(Substring.self) let destination = Reference(Substring.self) let travelSearchRB = Regex { "I took a " Capture(as: transportMethod) { OneOrMore(.word) } " to " Capture(as: transportMethod) { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match[transportMethod])") print("Destination: \(match[destination])") }

Slide 170

Slide 170 text

No content

Slide 171

Slide 171 text

let transportMethod = Reference(Substring.self) let destination = Reference(Substring.self) let travelSearchRB = Regex { "I took a " Capture(as: transportMethod) { OneOrMore(.word) } " to " Capture(as: transportMethod) { OneOrMore(.word) } /./ } let matches = route.matches(of: travelSearch) for match in matches { print("\nTransport method: \(match[transportMethod])") print("Destination: \(match[destination])") }

Slide 172

Slide 172 text

! WeatherKit

Slide 173

Slide 173 text

No content

Slide 174

Slide 174 text

!

Slide 175

Slide 175 text

No content

Slide 176

Slide 176 text

func getForecast(for location: CLLocation) async throws -" CurrentWeather { try await WeatherService .shared .weather(for: location, including: .current) }

Slide 177

Slide 177 text

func getForecast(for location: CLLocation) async throws -" Forecast { try await WeatherService .shared .weather(for: location, including: .hourly) }

Slide 178

Slide 178 text

func getForecast(for location: CLLocation) async throws -" Forecast { try await WeatherService .shared .weather(for: location, including: .daily) }

Slide 179

Slide 179 text

No content

Slide 180

Slide 180 text

1.00 USD ≈ 0.90 EUR* * As of 24 September 2024

Slide 181

Slide 181 text

Other fun stuff

Slide 182

Slide 182 text

Other fun stuff ‣ Variable color symbols in SFSymbols

Slide 183

Slide 183 text

Other fun stuff ‣ Variable color symbols in SFSymbols ‣ MapKit 3D, Look Around, and Server API support

Slide 184

Slide 184 text

Other fun stuff ‣ Variable color symbols in SFSymbols ‣ MapKit 3D, Look Around, and Server API support ‣ Better keyboard dismissal in SwiftUI

Slide 185

Slide 185 text

Other fun stuff ‣ Variable color symbols in SFSymbols ‣ MapKit 3D, Look Around, and Server API support ‣ Better keyboard dismissal in SwiftUI ‣ TextField Minimum and maximum lines / Auto-expansion

Slide 186

Slide 186 text

Other fun stuff ‣ Variable color symbols in SFSymbols ‣ MapKit 3D, Look Around, and Server API support ‣ Better keyboard dismissal in SwiftUI ‣ TextField Minimum and maximum lines / Auto-expansion ‣ Easy filtering of media type in PHPickerViewController

Slide 187

Slide 187 text

Other fun stuff ‣ Variable color symbols in SFSymbols ‣ MapKit 3D, Look Around, and Server API support ‣ Better keyboard dismissal in SwiftUI ‣ TextField Minimum and maximum lines / Auto-expansion ‣ Easy filtering of media type in PHPickerViewController ‣ Initial passkey support

Slide 188

Slide 188 text

Other fun stuff ‣ Variable color symbols in SFSymbols ‣ MapKit 3D, Look Around, and Server API support ‣ Better keyboard dismissal in SwiftUI ‣ TextField Minimum and maximum lines / Auto-expansion ‣ Easy filtering of media type in PHPickerViewController ‣ Initial passkey support ‣ 16.1: ActivityKit + Live Activities

Slide 189

Slide 189 text

Obligatory Summary Slide

Slide 190

Slide 190 text

Obligatory Summary Slide ‣ Tons of features to make working with SwiftUI easier

Slide 191

Slide 191 text

Obligatory Summary Slide ‣ Tons of features to make working with SwiftUI easier ‣ Otherwise awesome chart engine that lacks pie charts

Slide 192

Slide 192 text

Obligatory Summary Slide ‣ Tons of features to make working with SwiftUI easier ‣ Otherwise awesome chart engine that lacks pie charts ‣ Use TextKit 2 if you're well-tested or building something new

Slide 193

Slide 193 text

Obligatory Summary Slide ‣ Tons of features to make working with SwiftUI easier ‣ Otherwise awesome chart engine that lacks pie charts ‣ Use TextKit 2 if you're well-tested or building something new ‣ UI Toys: Bottom sheets, Multi-select calendar, DataScannerViewController

Slide 194

Slide 194 text

Obligatory Summary Slide ‣ Tons of features to make working with SwiftUI easier ‣ Otherwise awesome chart engine that lacks pie charts ‣ Use TextKit 2 if you're well-tested or building something new ‣ UI Toys: Bottom sheets, Multi-select calendar, DataScannerViewController ‣ Data Toys: WeatherKit, Transferrable protocol, SwiftRegex

Slide 195

Slide 195 text

Obligatory Summary Slide ‣ Tons of features to make working with SwiftUI easier ‣ Otherwise awesome chart engine that lacks pie charts ‣ Use TextKit 2 if you're well-tested or building something new ‣ UI Toys: Bottom sheets, Multi-select calendar, DataScannerViewController ‣ Data Toys: WeatherKit, Transferrable protocol, SwiftRegex ‣ This is definitely not an exhaustive list

Slide 196

Slide 196 text

Obligatory Summary Slide ‣ Tons of features to make working with SwiftUI easier ‣ Otherwise awesome chart engine that lacks pie charts ‣ Use TextKit 2 if you're well-tested or building something new ‣ UI Toys: Bottom sheets, Multi-select calendar, DataScannerViewController ‣ Data Toys: WeatherKit, Transferrable protocol, SwiftRegex ‣ This is definitely not an exhaustive list ‣ Poke around old videos, there's some fun stuff

Slide 197

Slide 197 text

No content

Slide 198

Slide 198 text

Links! ‣ Workaround for installing on old devices https:// forums.developer.apple.com/forums/thread/708901 ‣ What's new in Swift UI for iOS 16 https:// www.hackingwithswift.com/articles/250/whats-new-in- swiftui-for-ios-16 ‣ Migrating to new navigation types https:// developer.apple.com/documentation/swiftui/migrating-to- new-navigation-types

Slide 199

Slide 199 text

More Links! ‣ WWDC Speedrun https://appdevcon.nl/session/wwdc- speedrun/ ‣ Nerdy Internals of an Apple Text Editor https:// papereditor.app/internals ‣ Choosing a transfer representation for a model type https:// developer.apple.com/documentation/coretransferable/ choosing-a-transfer-representation-for-a-model-type ‣ Swift Regex Tester https://swiftregex.com/

Slide 200

Slide 200 text

Even more links! ‣ Why SwiftRegex requires iOS 16+ https://forums.swift.org/t/ why-the-new-features-in-swift-5-7-needs-the-latest-os- version-support/60952/16 ‣ Rendering SwiftUI views within UITableView or UICollectionView cells on iOS 16 https:// www.swiftbysundell.com/articles/rendering-swiftui-views- within-uitableview-or-uicollectionview/

Slide 201

Slide 201 text

WWDC Videos! ‣ The SwiftUI Cookbook for Navigation: https:// developer.apple.com/wwdc22/10054 ‣ Compose custom layouts with SwiftUI: https:// developer.apple.com/wwdc22/10056 ‣ Use SwiftUI from UIKit: https://developer.apple.com/ wwdc22/10072 ‣ DataScannerViewController: https://developer.apple.com/ videos/play/wwdc2022/10025/

Slide 202

Slide 202 text

More WWDC Videos! ‣ Meet TextKit 2 (2021): https://developer.apple.com/ wwdc21/10061 ‣ What's new in TextKit and TextViews (2022): https:// developer.apple.com/wwdc22/10090 ‣ What's new in SwiftUI (2022 Edition): https:// developer.apple.com/wwdc22/10052 ‣ Meet Transferrable: https://developer.apple.com/ wwdc22/10062 ‣ Meet Swift Regex: https://developer.apple.com/

Slide 203

Slide 203 text

Yet More WWDC Videos! ‣ Swift Regex: Beyond the basics: https://developer.apple.com/ wwdc22/110358 ‣ Meet WeatherKit: https://developer.apple.com/ wwdc22/10003 ‣ Adopt Variable Color in SFSymbols: https:// developer.apple.com/wwdc22/10158 ‣ Live Text Interaction: https://developer.apple.com/videos/ play/wwdc2022/10026