See https://stackoverflow.com/a/78358737/292145
Post
Replies
Boosts
Views
Activity
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/
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?
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
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"
}
}
}
I'll guess they will not change it. This will be the default behavior.Would be great to see a new API for screen savers at anytime in the future.