Post

Replies

Boosts

Views

Activity

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" } } }
Topic: App & System Services SubTopic: Core OS Tags:
Sep ’22
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?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
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" } } }
Topic: App & System Services SubTopic: Core OS Tags:
Replies
Boosts
Views
Activity
Sep ’22
Reply to IntentDonationManager not donating Shortcuts
+1
Topic: App & System Services SubTopic: General Tags:
Replies
Boosts
Views
Activity
Jan ’23
Reply to Debug SIGTERM handler in Xcode?
You can put a breakpoint that executes the lldb command and automatically continues somewhere in your app startup code. See https://stackoverflow.com/a/25631359/292145
Replies
Boosts
Views
Activity
Jan ’23
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?
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Apr ’23
Reply to Is it not recommended to modify and read individual properties in an actor instance?
I think they want to say, that a state machine that is implemented as an actor and used within another actor is not a good fit. See https://swiftsenpai.com/swift/actor-reentrancy-problem/
Replies
Boosts
Views
Activity
Jun ’23
Reply to 'ID' is inaccessible due to '@_spi' protection level
See https://stackoverflow.com/a/78358737/292145
Replies
Boosts
Views
Activity
Jun ’24