Post

Replies

Boosts

Views

Activity

Reply to NavigationSplitView 2-column loses state when minimized on iPad
I can confirm the exact same behaviour (Xcode 14.3 (14E222b) on macOS 13.3.1 (22E261)). My sample code is this: import SwiftUI enum ListEntry: String, Identifiable { var id: String { rawValue } case banana case kiwi case orange } struct ContentView: View { var elements: [ListEntry] = [.banana, .kiwi, .orange] @State var selection: String? = nil var body: some View { NavigationSplitView { List(elements, selection: $selection) { e in Text("\(e.rawValue)") }.onChange(of: selection) { newValue in print("newValue = \(newValue ?? "<nil>")") } // } content: { // Text("Content") } detail: { Text("Selection \(selection ?? "<nil>")") } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView().previewInterfaceOrientation(.landscapeLeft) } } Did you come up with a solution / workaround?
Apr ’23
Reply to How to signal errors / failures in App Intents?
I couldn't find any documentation on this, but during the migration of my intents I ended up using a property localizedStringResource like this: struct MyIntent: AppIntent { static let title: LocalizedStringResource = "Start My Intent" func perform() async throws -> some IntentResult { if !doSomething() { throw MyIntentError.message("Hello, I'm an error!") } return .result(dialog: IntentDialog("My answer")) } func doSomething() -> Bool { return false } } enum MyIntentError: Swift.Error, CustomLocalizedStringResourceConvertible { case general case message(_ message: String) var localizedStringResource: LocalizedStringResource { switch self { case let .message(message): return "Error: \(message)" case .general: return "My general error" } } }
Sep ’22