Post

Replies

Boosts

Views

Activity

Reply to SwiftData Transformable with String Array
Ok, I think I figured it out. So.. when you generate SwiftData Objects from Core Data and if you have Transformable Data like above what I've done with an Array of Strings, you will get @Attribute(.transformable(by: "NSSecureUnarchiveFromData")) var yourArrayOfStrings: [String]? However, SwiftData is so good that it already recognizes these Array of Strings so having that Attribute confuses Xcode to thinking you're using NSKeyedUnarchiveFromData. The solution is to just delete that attribute like so... var yourArrayOfStrings: [String]? And it just works! The warning goes away in the Debugger.
Mar ’24
Reply to SwiftData error: NSKeyedUnarchiveFromData' should not be used to for un-archiving and will be removed in a future release
Same issue with my transformable array of strings in Xcode 15.2 and iOS 17.3. I'm switching from CoreData to SwiftData and using NSSecureUnarchiveFromData. But still get this error and then the app crashes due to memory. Frustrating I can't move to SwiftData after all of the work I put into changing my code. Good thing I saved a copy of the CoreData version. https://developer.apple.com/forums/thread/744688
Jan ’24
Reply to Remove macOS app from the App Store
Same issue. I'm waiting for an Apple Silicon Macbook Pro and my current Mac doesn't support Big Sur so I can't test. I got the macOS version approved but unapproved on an update due to Catalyst's messiness. Nobody has downloaded the app from the Mac App Store anyways, so I'd rather remove that and wait till I get a new Mac rather than just blindly compiling for Mac App Review and praying. I'm thinking the only solution is to remove the app entirely and resubmitting.
Sep ’20
Reply to Issue with .sheet() Passing String to a View in SwiftUI 2.0
Ok, here's the code. Part of the first view. You can see that I pass the ship name to a view in .sheet struct ShipEditorView: View {       @Environment(\.managedObjectContext) var managedObjectContext   @FetchRequest(fetchRequest: Ship.getAllShips()) var ships:FetchedResults<Ship>       @State private var newShip = ""   @State var shipSelected = ""       @State var showingAddShipAlert = false   @State var showingShipEditor = false   @State var edit = false       var body: some View {     ZStack(alignment: .bottomTrailing){       VStack{         List{           ForEach(self.ships) { ship in             if self.edit == true {               Button(action: {                 print("Opens Ship Editor")                 self.shipSelected = ship.shipName!                 self.showingShipEditor = true               }) {                 Text(ship.shipName!)               }               .sheet(isPresented: self.$showingShipEditor) { ShipEditingView(shipName: self.shipSelected) }             } else {               NavigationLink(destination: ProductEditorView(shipName: ship.shipName!)) {                 Text(ship.shipName!)               }             }                         } .onDelete {indexSet in ... Then the second view. When this view shows up, the ship textfield is blank. I even tried printing the shipName and shipText and nothing shows up. struct ShipEditingView: View {   let shipName: String       @Environment(\.presentationMode) var mode: Binding<PresentationMode>   @State var context: NSManagedObjectContext!       @State var shipText = ""       var body: some View {     NavigationView{       VStack{         Form{           Section(header: Text("Rename Ship")) {             TextField("Titanic", text: $shipText)               .font(.title)               .textFieldStyle(RoundedBorderTextFieldStyle())           }         }         Button(action: {           self.saveEdits()           self.mode.wrappedValue.dismiss()         }) {           Text("Done")             .font(.title)         }         Spacer()       }       .navigationBarTitle(Text("Rename Ship"))       .onAppear() {         self.shipText = self.shipName       }     }.navigationViewStyle(StackNavigationViewStyle())   }       func saveEdits() { ... I'm wondering if it's a bug with SwiftUI. Running Beta 8 and I've noticed that if I tap on the ship I want to edit and dismiss the sheet a few times, then the ship name will show up in the textfield and never fails with different ships after that.
Sep ’20