Posts

Post marked as solved
2 Replies
437 Views
I am doing a full transition of an app from CoreData to SwiftData. I was able to follow the online guides and extract SwiftData objects from the CoreData model. Everything seems to work except for my Transformable String Arrays. This app is storing CoreData in iCloud. In my SwiftData model, I have a variable... @Attribute(.transformable(by: "NSSecureUnarchiveFromData")) var arrayofStrings: [String]? The app is able to read the array of strings, however, the debugger gives me this error eventually crashing due to memory. 'NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release I don't understand, the transformed variable already is 'NSSecureUnarchiveFromData' not 'NSKeyedUnarchiveFromData'. That's the reason why I used NSSecureUnarchiveFromData in my CoreData model because NSKeyedUnarchiveFromData is being phased out. I don't get why the debugger thinks otherwise. Any thoughts?
Posted
by phspman.
Last updated
.
Post not yet marked as solved
1 Replies
593 Views
I have a SwiftUI view that uses Geometry so that I can manipulate an Image by touch gestures. It stopped working under a .sheet view in iOS 16.4. It works fine in a normal view, just not in sheet view. I believe this is a Bug on Apple's end and I am open for any alternative ideas as it's not doing good to my app customers. I don't like to but I could just go back to a UIViewRepresentative. Here's some Code for Testing import SwiftUI struct SheetImageTest: View { @State var showView = false var body: some View { Button(action: {showView.toggle()}){ Text("Show Image") } .sheet(isPresented: $showView) { ImageTouchableView(image: "YourImage") } } } struct SheetImageTest_Previews: PreviewProvider { static var previews: some View { SheetImageTest() } } Manipulative Image View import SwiftUI struct ImageTouchableView: View { let image: String //Scale Stuff @State private var scale: CGFloat = 1.0 @State private var tapped = false //Drag Stuff @State private var location: CGPoint = CGPoint(x: 50, y: 50) @GestureState private var fingerLocation: CGPoint? = nil @GestureState private var startLocation: CGPoint? = nil // 1 var simpleDrag: some Gesture { DragGesture() .onChanged { value in var newLocation = startLocation ?? location // 3 newLocation.x += value.translation.width newLocation.y += value.translation.height self.location = newLocation }.updating($startLocation) { (value, startLocation, transaction) in startLocation = startLocation ?? location // 2 } } //Size Stuff @State private var size = CGSize(width: 100, height: 100) var pinchZoom: some Gesture { MagnificationGesture() .onChanged { value in self.scale = value.magnitude } } var body: some View { GeometryReader { geometry in Image(image) .resizable() .scaleEffect(scale) .scaledToFit() .position(location) .gesture(simpleDrag) .gesture(pinchZoom) .onAppear(){ location = CGPoint(x: geometry.size.width/2, y: geometry.size.height/2) size = CGSize(width: geometry.size.width, height: geometry.size.height) } .frame(width: size.width, height: size.height) .onTapGesture(count: 2, perform: { tapped.toggle() if tapped { scale += 1.0 location = CGPoint(x: geometry.size.width/2, y: geometry.size.height/2) } else { scale -= 1.0 location = CGPoint(x: geometry.size.width/2, y: geometry.size.height/2) size = CGSize(width: geometry.size.width, height: geometry.size.height) } }) .animation(.default, value: scale) } } } struct ImageTouchableView_Previews: PreviewProvider { static var previews: some View { ImageTouchableView(image: "YourImage") } }
Posted
by phspman.
Last updated
.
Post marked as solved
4 Replies
4.8k Views
I wrote an app in SwiftUI last year and it's on the App Store. I am working on it in XCode 12 for iOS 14. When I pass a string to a View in .sheet, the String won't get passed. It worked in SwiftUI 1.0, but now doesn't in SwiftUI 2.0. I tested this by printing the variable right before passing to the view and it shows but doesn't print when the new view is opened in .sheet. Anyone having this issue? Running XCode 12 Beta 6 & iOS 14 Beta 7
Posted
by phspman.
Last updated
.