Post

Replies

Boosts

Views

Activity

Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
As of Xcode 16.3 beta 2, this issue is still not resolved. Additionally, updating the id (however that is achieved), as per the workaround in this thread, no longer triggers the Query to refresh;- I just added a button to the form that updates the id, and, after performing updates via a background modelActor, pushing the button did not trigger a refresh.
Mar ’25
Reply to Xcode 16 Beta: Animatable + non isolated protocol requirement errors.
Interestingly enough, you can get animatableData to work if you mark the computed variable as nonisolated. Xcode will fail at previewing the result, but a live run shows it working.. struct ContentView: View { static let bigAngle = 60.0 static let smallAngle = 10.0 @State var angle = Self.bigAngle var body: some View { MyShape(angle: angle) .foregroundStyle(.tint) .frame(width: 300, height: 200) .animation(.smooth(duration: 1.0), value: angle) .onTapGesture { angle = angle == Self.bigAngle ? Self.smallAngle : Self.bigAngle } } } struct MyShape: Shape { init(angle: Double) { self.angle = angle } var angle: Double nonisolated var animatableData: Double { get {angle} set {angle = newValue } } func path(in rect: CGRect) -> Path { Path { path in path.move(to: CGPoint(x: 0, y: 0)) // top left path.addLine(to: CGPoint(x: max(0,rect.width - rect.height*tan(angle * .pi/180)), y: 0)) // top right (or top left if the angle is large enough) path.addLine(to: CGPoint(x: rect.width, y: rect.height)) //bottom right path.addLine(to: CGPoint(x: 0, y: rect.height)) // bottom left path.closeSubpath() // Close (back to top left) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Jul ’24
Reply to Importing Data into SwiftData in the Background Using ModelActor and @Query
As of Xcode 16.3 beta 2, this issue is still not resolved. Additionally, updating the id (however that is achieved), as per the workaround in this thread, no longer triggers the Query to refresh;- I just added a button to the form that updates the id, and, after performing updates via a background modelActor, pushing the button did not trigger a refresh.
Replies
Boosts
Views
Activity
Mar ’25
Reply to Xcode 16 Beta: Animatable + non isolated protocol requirement errors.
Interestingly enough, you can get animatableData to work if you mark the computed variable as nonisolated. Xcode will fail at previewing the result, but a live run shows it working.. struct ContentView: View { static let bigAngle = 60.0 static let smallAngle = 10.0 @State var angle = Self.bigAngle var body: some View { MyShape(angle: angle) .foregroundStyle(.tint) .frame(width: 300, height: 200) .animation(.smooth(duration: 1.0), value: angle) .onTapGesture { angle = angle == Self.bigAngle ? Self.smallAngle : Self.bigAngle } } } struct MyShape: Shape { init(angle: Double) { self.angle = angle } var angle: Double nonisolated var animatableData: Double { get {angle} set {angle = newValue } } func path(in rect: CGRect) -> Path { Path { path in path.move(to: CGPoint(x: 0, y: 0)) // top left path.addLine(to: CGPoint(x: max(0,rect.width - rect.height*tan(angle * .pi/180)), y: 0)) // top right (or top left if the angle is large enough) path.addLine(to: CGPoint(x: rect.width, y: rect.height)) //bottom right path.addLine(to: CGPoint(x: 0, y: rect.height)) // bottom left path.closeSubpath() // Close (back to top left) } } }
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’24
Reply to Xcode 16 Beta: Animatable + non isolated protocol requirement errors.
ideally the protocols would be updated and restricted to main actor, but I don’t hold out much hope for that based on other threads I have read.
Topic: UI Frameworks SubTopic: SwiftUI Tags:
Replies
Boosts
Views
Activity
Jul ’24