Posts

Post marked as solved
2 Replies
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.
Post marked as solved
2 Replies
Here is what the Transformer looks like in the CoreData version of the app. I tried changing to @Attribute(.transformable(by: "NSSecureUnarchiveFromDataTransformer")) too.
Post not yet marked as solved
9 Replies
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.
Post marked as solved
4 Replies
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.
Post not yet marked as solved
2 Replies
Same issue, I think it's a bug.