Post

Replies

Boosts

Views

Activity

Reply to SwiftData Unexpected type for CompositeAttribute
The error message isn't very clear, but I think what it's trying to convey is that the type you're using isn't compatible with SwiftData (at least not yet). The reason that others have said to use a computed property instead is because you can save the data you actually need to recreate the type that doesn't work. You're already halfway doing that. I think if you were to remove the @Transient and move the clLocation assignment from your initializer into a computed property, it would work. struct SomeStruct : Codable { var latitude: Double var longitude: Double // doesn't need to be @Transient if it's computed var clLocation: CLLocationCoordinate2D { CLLocationCoordinate2D(latitude: latitude, longitude: longitude) } init(latitude: Double, longitude: Double) { self.latitude = latitude self.longitude = longitude } You did mention that I'm trying to cache instances of CLLocationCoordinate2D, rather than creating new ones every time a View renders, so those work arounds don't work around. I don't think it's all that expensive to create the CLLocationCoordinate2D as a computed property when you already have the latitude and longitude handy, but I could be mistaken.
Feb ’24
Reply to DragGesture in SwiftUI ScrollView fails
Have you tried using the simultaneousGesture() modifier? I learned about it on Hacking with Swift. Here's the example code that Paul gives: struct ContentView: View { 		var body: some View { 				VStack { 						Text("Hello, World!") 								.onTapGesture { 										print("Text tapped") 								} 				} 				.simultaneousGesture( 						TapGesture() 								.onEnded { _ in 										print("VStack tapped") 								} 				) 		} } I don't know if this will help or not, but it might since the ScrollView already has a gesture that seems like it might be overriding yours.
Aug ’20