Posts

Post not yet marked as solved
0 Replies
405 Views
Hallo, in my app I have add a new Entity. When I run the app with xcode on my iPhone then everything works well and the synchronization works perfect, also with the new Entity. When I make build (I have the Entity in the Development and the Production in the Container) and install via Testflight, then the synchronizations of the Data for the Old Entity works perfect. I can add or edit or delete and it works. But when I add one value to the new Entity, then on the iPhone it be saved and can be used, but the full synchronization stops. For the new Entity also like for the Entities that I had before. When I uninstall the app and reinstall via Testflight, then it loaded the Data that I had in the App until i try to add a value to the new Entity. This is the function: private func saveItem() { let request: NSFetchRequest<ToolsSectionsEntity> = ToolsSectionsEntity.fetchRequest() request.predicate = NSPredicate(format: "sectionName == %@", inputSectionName) do { let existingSections = try viewContext.fetch(request) if let editingSection = editingSection { if existingSections.isEmpty || (existingSections.count == 1 && existingSections.first == editingSection) { editingSection.sectionName = inputSectionName do { try viewContext.save() updateTools(sectionID: editingSection.wrappedUniqueID, sectionName: inputSectionName) if selectedSectionUniqueID == editingSection.wrappedUniqueID { selectedSectionName = inputSectionName } } catch { // Fehler beim Speichern print("Fehler beim Speichern: \(error.localizedDescription)") } } else { alertMessage = NSLocalizedString("no double name", comment: "No double name") showingAlert = true } } else { if existingSections.isEmpty { let newSection = ToolsSectionsEntity(context: viewContext) newSection.uniqueID = UUID().uuidString // String der UUID newSection.sectionName = inputSectionName do { try viewContext.save() } catch { // Fehler beim Speichern print("Fehler beim Speichern: \(error.localizedDescription)") } } else { alertMessage = NSLocalizedString("no double name", comment: "No double name") showingAlert = true } } } catch { // Fehler beim Speichern oder Abrufen cloudresult = "Fehler beim Speichern: \(error.localizedDescription)" print("Fehler beim Speichern oder Abrufen: \(error.localizedDescription)") } } And i got no error in the catch.
Posted
by Rol4nd.
Last updated
.
Post not yet marked as solved
0 Replies
617 Views
Hallo, in my coudkitcontainer i have the following structure: RECORD TYPE CD_ToolsEntity ( CD_ankle DOUBLE QUERYABLE SORTABLE, CD_cuttingToolHolder STRING QUERYABLE SEARCHABLE SORTABLE, CD_entityName STRING QUERYABLE SEARCHABLE SORTABLE, CD_favoriteFrontbase INT64 QUERYABLE SORTABLE, CD_imagename STRING QUERYABLE SEARCHABLE SORTABLE, CD_inGrindDirection INT64 QUERYABLE SORTABLE, CD_name STRING QUERYABLE SEARCHABLE SORTABLE, CD_remark STRING QUERYABLE SEARCHABLE SORTABLE, CD_sectionUniqueID STRING QUERYABLE SEARCHABLE SORTABLE, CD_sectionUniqueName STRING QUERYABLE SEARCHABLE SORTABLE, CD_uniqueID STRING QUERYABLE SEARCHABLE SORTABLE, "___createTime" TIMESTAMP, "___createdBy" REFERENCE, "___etag" STRING, "___modTime" TIMESTAMP, "___modifiedBy" REFERENCE, "___recordID" REFERENCE, GRANT WRITE TO "_creator", GRANT CREATE TO "_icloud", GRANT READ TO "_world" ); RECORD TYPE CD_ToolsSectionsEntity ( CD_sectionName STRING QUERYABLE SEARCHABLE SORTABLE, CD_uniqueID STRING QUERYABLE SEARCHABLE SORTABLE, "___createTime" TIMESTAMP, "___createdBy" REFERENCE, "___etag" STRING, "___modTime" TIMESTAMP, "___modifiedBy" REFERENCE, "___recordID" REFERENCE, GRANT WRITE TO "_creator", GRANT CREATE TO "_icloud", GRANT READ TO "_world" ); Can it be, that the CD_uniqueID, that I have made as string in both entity be a problem? Is for the cloudkitdatabase needed that every fieldname have to be unique in the hole structure?
Posted
by Rol4nd.
Last updated
.