core-data

Core Data information in application

北城以北 提交于 2020-01-03 04:40:07
问题 I have an app that I'm building where it has some data built into it that is contained in a core data data model. When I run the app to the simulator, the data is there and everything is peachy. However, when I deploy the app to the device (an iPad), the app works fine, except there is no data. Seems like a no brainer, but can't seem to find a switch or check box or anything to tell xcode to deploy the data along with the model. Update: The suggested duplicate didn't really help me. I'm not

RestKit Relation Mapping Many to Many Core Data relationship fault error

时光毁灭记忆、已成空白 提交于 2020-01-03 04:32:20
问题 I am using RestKit to map the following JSON to core data. I have a many-to-many relationship set up in core data. A hopper can have many users and a user can have many hoppers. I am getting this error message: (entity: Hopper; id: 0x767d240 hopperToUsers = <relationship fault: 0x8352960 'hopperToUsers' ; So none of my users are being updated. The json: { "hoppers": [{ "bearing": 0, "created_at": "2013-07-26T07:57:00Z", "distance": 0.0, "id": 4, "lat": "30.422032", "lng": "-86.617069", "name"

NSFetchedResultsController does not update TableView after UIManagedDocuments gets new data

限于喜欢 提交于 2020-01-03 03:34:13
问题 I am using a NSFetchedResultsController in combination with a UIManagedDocument which gets updated in an background thread. I have set up the NSFetchedResultsController exactly as described in this tutorial: How To Use NSFetchedResultsController I have set the delegate _fetchedResultsController.delegate = self and the protocol for my view controller to NSFetchedResultsControllerDelegate . My code works fine when it loads the data after launch. However, the NSFetchedResultsController does not

NSManagedObjectContext does not see changes (“hasChanges” always false)

依然范特西╮ 提交于 2020-01-03 02:56:12
问题 I have what I thought is a very simple setup using core data: one NSManagedObjectContext and two NSFetchedResultsController s. The app has its own subclass of NSManagedObject . What I do is more or less the following (pseudo code/flow): 1. create an NSFetchRequest -> with it an NSFetchedResultsController (and attach an NSFetchedResultsControllerDelegate) 2. fetch the objects from the store 3. create another NSFetchRequest (in/from/with the same context) -> with it a second

Adding values to coredata in swift share extension

自作多情 提交于 2020-01-03 02:45:07
问题 I need to insert and fetch data from coredata in swift share extension. How can I do this class ShareViewController: SLComposeServiceViewController,NetworkSelectionViewControllerDelegate, PublishSelectionViewControllerDelegate,ApproverSelectionViewControllerDelegate{ var selectedNetworkName = "Default" var selectedPublishName = "Select" var selectedApproverName = "Select" override func isContentValid() -> Bool { // Do validation of contentText and/or NSExtensionContext attachments here return

Why entries are not deleted until app is restarted or I execute my NSBatchDeleteRequest twice?

风流意气都作罢 提交于 2020-01-03 02:19:36
问题 I'm reading Delete/Reset all entries in Core Data?. If I follow the steps below, I get an unexpected result: Call the code below Then query an entity in the simulator, I will get an entity back!!! If I call clearCoreDataStore again (or do a restart), only then the value won't be retrieved from core-data What am I missing? func clearCoreDataStore() { let entities = dataManager.persistentContainer.managedObjectModel.entities for entity in entities { let fetchRequest = NSFetchRequest

Can Managed Object Contexts in different threads (main/private queues) handle the same objects?

倾然丶 夕夏残阳落幕 提交于 2020-01-03 01:51:24
问题 I have an NSManagedObjectContext in the main queue (the default context provided in AppDelegate ), and I create another NSManagedObjectContext in a private queue to request data updates to web services. I use the main context to fetch all the objects to be shown and managed throughout the app, and I use the private context to insert the new objects I receive from services to avoid blocking the UI and to also avoid "interfering" with the objects in the main context in case the user and/or the

Core Data: Memory not released after manually faulting managed objects

孤人 提交于 2020-01-03 01:22:45
问题 I am using the following code to retrieve the maximum value of an attribute on Core Data - (NSDate*)latestDateForLocalEntity:(NSString*)entityString key:(NSString*)key inManagedObjectContext:(NSManagedObjectContext*)context { NSFetchRequest *request = [NSFetchRequest fetchRequestWithEntityName:entityString]; NSSortDescriptor *sortDescriptor = [NSSortDescriptor sortDescriptorWithKey:key ascending:YES]; request.sortDescriptors = @[sortDescriptor]; NSError *localError; NSArray *localResults =

How to fetch one to many relationship in core data?

烂漫一生 提交于 2020-01-02 23:04:07
问题 Let say the data entities are: Bookshop <--->> Books How do I fetch all books belonging to a specific book shop that contain "cloud" in the name for example? The following method feel clunky. Bookshop *bookshop = (Bookshop *) nsManagedObjectFromOwner; NSString *searchTerm = @"cloud"; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForName:@"Books" inManagedObjectContext:self.managedObjectContext]; [fetchRequest setEntity

How to properly group a list fetched from CoreData by date?

橙三吉。 提交于 2020-01-02 16:08:31
问题 For the sake of simplicity lets assume I want to create a simple todo app. I have an entity Todo in my xcdatamodeld with the properties id , title and date , and the following swiftui view (example pictured): import SwiftUI struct ContentView: View { @Environment(\.managedObjectContext) var moc @State private var date = Date() @FetchRequest( entity: Todo.entity(), sortDescriptors: [ NSSortDescriptor(keyPath: \Todo.date, ascending: true) ] ) var todos: FetchedResults<Todo> var dateFormatter: