Post

Replies

Boosts

Views

Activity

Reply to NavigationStack and NavigationSplitView Runtime warnings
Confusion about NavigationSplitView There seem to be 2 ways: Option 1: WWDC video (https://developer.apple.com/wwdc22/10054) uses NavigationLink for NavigationSplitView Option 2: Documentation (https://developer.apple.com/documentation/swiftui/navigationsplitview) they don't use NavigationLink Not sure what is the correct approach, using NavigationLink seems to require navigationDestination but that doesn't sit well with NavigationSplitView as the destination view is specified part of the detail closure and repeating the code would be redundant. Following the documentation (without NavigationLink): Following https://developer.apple.com/documentation/swiftui/navigationsplitview documentation things seem to work ok, there is only one warning thrown (as opposed to 3 before): Update NavigationAuthority bound selection tried to update multiple times per frame. The other 2 warnings about navigationDestination and Focus are not thrown I really wish someone from the Apple team could clarify on this, please.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Rewrite UIKit to SwiftUI
If you are new to SwiftUI it might be best to invest some time understanding the fundamentals of SwiftUI. It is different from UIKit, if you invest time up front you would save time on the long run. WWDC has some great content for SwiftUI, you could start with https://developer.apple.com/wwdc20/10119 and https://developer.apple.com/wwdc20/10040. Once you are done with it you can view other links under the videos.
Topic: UI Frameworks SubTopic: UIKit Tags:
Jun ’22
Reply to Binding issue
Short answer If you are using Binding<SomeType>, then use wrappedValue If you are using @Binding propertyWrapper then using just the variable name should give the value Long Answer import SwiftUI struct Something { //This is using the Binding propertyWrapper @Binding var price1: Int func f1() { price1 //Int value $price1 //Binding to the Int let price2 = $price1 //Type of price2 is Binding<Int> price2.wrappedValue //Int value } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to Pass on Binding
Learn It would be best if you could learn about Binding, there is a convenient propertyWrapper @Binding Refer: https://developer.apple.com/documentation/swiftui/binding/ Sample code struct ContentView: View { //This is using the Binding propertyWrapper @Binding var data: [TodoItem] var body: some View { List { ForEach($data) { datum in TableRow(data: datum) // <- what goes here? .swipeActions { Button(role: .destructive) { data.delete(datum) //data.removeAll { $0 == datum.wrappedValue } } label: { Label("Delete", systemImage: "trash") } } } } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jun ’22
Reply to NavigationStack and NavigationSplitView Runtime warnings
NavigationStack - Works as expected The following code works as expected struct ContentView: View { @StateObject private var dataStore = DataStore() @State private var navigationPath = [Car]() var body: some View { NavigationStack(path: $navigationPath) { List { ForEach(dataStore.cars) { car in NavigationLink(car.name, value: car) } } .navigationDestination(for: Car.self) { car in CarDetail(car: car, navigationPath: $navigationPath) } .navigationTitle("Car List") } } } NavigationSplitView - Doesn't work on compact width (iPhone) The problem with NavigationSplitView is that on iPhone (compact width - behaves like pushing views) the following happens: Select one cell and going into the detail view Press back to come parent view Select another cell, nothing happens, it just selects the cell but doesn't push to the detail view
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’22
Reply to Drag file from app to Finder on macOS
This seems like a bug, it works fine on iOS but macOS it doesn't work Please file a bug and post the feedback ID. The only workaround for now is to use ProxyRepresentation Note: ProxyRepresentation has a different purpose to serve as a proxy, but since the bug that is the only workaround I can think of.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22
Reply to ShareLink and DataRepresentation
Try it on iOS (iPad Simulator), try to share it and locally save it to Files locally on the iPad (you don't need iCloud) If it works then your code is fine, I feel transferable on macOS has a lot of bugs. After testing and confirming the issue, it would be great if you could file a feedback.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Aug ’22