Questions tagged core-data

Explore the latest questions and answers asked by our top developers.

Deleting CoreData Item which is also an @ObservedObject in DetailView causing App Crash in Swift 5

I am currently working with SwiftUI and CoreData. Situation: I have a User Detail View with a Delete Button. When pressed, the Core Data Entry of the User is getting deleted and the App Navigation goes back to the Root Navigation View, which is a List of all Users. Problem: Every Time the Delete Button […]

By christophriepe
Published
Categorised as core-data, ios, observedobject, swift, swiftui Tagged , , , ,

Sharing model between documents in a document-based app

My app is a document-based and uses NSPersistentDocument to manage its Core Data stack. It works great when each document has its own data, but now I want documents to share parts of their model. In my case, the users import large files and I don’t want to copy them for each document. I want […]

By msmialko
Published
Categorised as core-data, ios, macos Tagged , ,

SwiftUI: How do I update a List that is driven by a static set of data and pulls bits of information from another dynamic set of data?

I’m not even sure the title question makes sense. Please carry on reading regardless 🙂 I have a SwiftUI view that is using a peculiar combination of a "fixed" data structure and data from Core Data, and I’m struggling to understand how to make the two cooperate. I am pretty sure this is not something […]

By Morpheu5
Published
Categorised as core-data, swift, swiftui Tagged , ,

Exporting Package.swift for Swift Package Manager from existing Xcode project

I’m working with Xcode 11.3 on macOS Catalina 10.15.6. I have an existing Xcode project which builds an app for iOS. I am interested in reusing some of the classes in an interactive session with the swift command line interpreter. The classes I want to work with are Core Data classes which are autogenerated from […]

SwiftUI Preview Does Not Work with Core Data when Entity Injected in View

I’ve been frustrated for months trying to get previews to work in Xcode when Core Data is used. I can definitely make the preview work for the views that don’t include an injected item. But not any subsequent views that depend on the source Entity. Let’s say I have a master/detail-like SwiftUI project with ContentView […]

By user2698617
Published
Categorised as core-data, ios, swiftui, xcode Tagged , , ,

Crash occurs when executing Share Extension twice in system Files to share file to app

Anyone could reproduce the bug by downloading this demo project. The app uses Share Extension to import a string of .txt files to Core Data. And then syncs the Core Data to iCloud. There is an entity called Item. When sharing a new item in system Files through Share Extension, the code needs to calculate […]

By Muz
Published
Categorised as core-data, icloud, ios, ios8-share-extension, swift

iOS data saved in Core Data doesn’t survive launch

I’m building a game in which users create coins as rewards for various achievements. The coins are saved as managed objects in Core Data, with their various attributes. They are retrieved for various reasons, have their attributes modified, etc., during game play. Everything saves and retrieves perfectly until I quit and relaunch, at which point […]

By rattletrap99
Published
Categorised as core-data, ios, swift

Should I ignore _NSCoreDataConstraintViolationException?

For some reason I only recently found out about unique constraints for Core Data. It looks way cleaner than the alternative (doing a fetch first, then inserting the missing entities in the designated context) so I decided to refactor all my existing persistence code. If I got it right, the gist of it is to […]

By dariaa
Published
Categorised as core-data, nsmanagedobjectcontext, objective-c, persistence, swift

Is it possible to source an up-to-date snapshot from an NSFetchedResultsController

As of iOS 13, the easiest way to keep a UITableView in sync with a NSFetchedResultsController seems to be with snapshots. The NSFetchedResultsController vends a snapshot reference to its delegate whenever the managedObjectContext reports additions, deletions, or updates. When using snapshots (NSDiffableDataSourceSnapshot), there is only one FRC delegate method that needs to be implemented: controller(_:didChangeContentWith:). […]

By Small Talk
Published
Categorised as core-data, ios, ios13, swift

How to wait until cloud kit data is being synced with core data in swift in iOS13

I developed core data based app and implemented iCloud sync feature after it was introduced in iOS 13. I enabled iCloud kit, used NSPersistentCloudKitContainer instead of NSPersistentContainer and added several lines of code to sync core data with iCloud. Sync works fine. The problem is that when I uninstall app and reinstall app, it doesn’t […]

By ZhengGe Che
Published
Categorised as core-data, icloud, ios, swift
1 2 3 5

Still Have Questions?


Our dedicated development team is here for you!

We can help you find answers to your question for as low as 5$.

Contact Us
faq