Post

Replies

Boosts

Views

Activity

Reply to CoreData + Picker: confusion
I digged more into the topic and the problem is not in the picker actually, but in CoreData. What I have is an ActionSheet where I can create a new "Product" entity; in this sheet there is a picker to pick a storage location which is basically another entity. The function addProduct will save then to CoreData private func addProduct(id: UUID, name: String, actualQty: Int, expDate: Date, location: StorageLocation) { withAnimation { let newItem = Product(context: viewContext) newItem.id = id newItem.name = name newItem.qty = Int32(actualQty) newItem.expDate = expDate location.addToProducts(newItem) After having watched few CoreData videos/tutorials, I understood I have to use the function "addToProducts" provided by the CoreData classes. But when I do this, I get the following error: Thread 1: "-[StorageLocation addProductsObject:]: unrecognized selector sent to instance 0x600000abcf40" and the app crashes; I looked for the error, but everything I found was an incosistency between model and classes, but this is not my case. Any idea/hints? Thanks Marco
Apr ’21