core-data

How to map nested complex JSON objects and save them to core data?

吃可爱长大的小学妹 提交于 2020-01-02 15:47:49
问题 I'm having problem with mapping and saving complex nested JSON data to Core data objects. It's meant for reading the data in case of offline mode and caching. JSON also has codes, which represent an id of an object in code list. Nesting depth of object in JSON can be between 5-8 objects. Example of such (simplified) JSON would be something like this (Person object): https://pastebin.com/nKSFa5cp Example of code list for relatedPerson: { "relatedPerson": [ { "code": 1, "description": "Mom" },

How to map nested complex JSON objects and save them to core data?

心已入冬 提交于 2020-01-02 15:46:19
问题 I'm having problem with mapping and saving complex nested JSON data to Core data objects. It's meant for reading the data in case of offline mode and caching. JSON also has codes, which represent an id of an object in code list. Nesting depth of object in JSON can be between 5-8 objects. Example of such (simplified) JSON would be something like this (Person object): https://pastebin.com/nKSFa5cp Example of code list for relatedPerson: { "relatedPerson": [ { "code": 1, "description": "Mom" },

Importing a MySQL schema to Xcode as a CoreData Data Model

孤街醉人 提交于 2020-01-02 12:25:33
问题 I have an existing MySQL database, I would like to import the schema into Xcode and create a Core Data data model. Is there a way (tool, process) to import the CREATE statements so I don't have to build the models "by hand"? As an intermediary step I could convert to SQLite, I'm not worried about the relationships, foreign keys etc just auto-generating the Entities (Tables) and Properties (Columns). 回答1: Actually I needed the feature so badly too that I have decided to make an OSX utility to

Accessing deleted objects in iCloud notification

大兔子大兔子 提交于 2020-01-02 10:32:57
问题 I have an app set up much like the iCloudCoreDataRecipes sample (ie, using Core Data in conjunction with iCloud). In the app delegate, I observe the NSPersistentStoreDidImportUbiquitousContentChangesNotification When a notification arrives, I call [context mergeChangesFromContextDidSaveNotification:note]; I have some additional processing I'd like to do when this notification is received but am having trouble using the objects identified by the NSManagedObjectID's present in the

IOS Coredata compatible with both IOS 9 and ios 10

孤街醉人 提交于 2020-01-02 09:59:52
问题 Hi I'm developing an app to work with both IOS 10 and 9 (xcode 8). What is the proper way to create new entity object? new IOS 10 has this code var newEvent = Event(context: context) How do we make this code work with both IOS 10 and 9? I'm testing using Mater-Detail template with coredata xcode8 Any additional change should we make to ensure coredata work with both IOS 9 and 10? any help is much appreciate. Thanks 来源: https://stackoverflow.com/questions/39687249/ios-coredata-compatible-with

NSManagedObjects with Categories

北慕城南 提交于 2020-01-02 09:59:12
问题 I believe it is a common practice to put custom code for a NSManagedObject in a category of the subclass since Xcode will overrite your generated subclass when the model is edited. I just wanted to confirm this. I have seen examples where people say it is bad to combine categories with methods that are already implemented in the class hierarchy. I'm not sure if this is just for the cases when the class that has the actual category has the method already implemented or in all cases. 回答1: The

Is there a way to modify fetched results with a predicate after they are initialized?

若如初见. 提交于 2020-01-02 09:56:21
问题 I am trying to build a search view for an existing CoreData app (simple logging app). I have all the data stored with CoreData and is fetched with the @FetchRequest : @State private var searchPredicate: NSPredicate? = NSPredicate(format: "title contains[c] %@", "") @FetchRequest( entity: Item.entity(), sortDescriptors: [NSSortDescriptor(keyPath: \Item.title, ascending: true)], predicate: NSPredicate(format: "title contains[c] %@", "h") ) var items: FetchedResults<Item> It now only fetches the

Appengine cloud endpoint messages and iOS Core Data

荒凉一梦 提交于 2020-01-02 09:12:42
问题 I have an endpoint message from Google Cloud Endpoint that I would like to persist in iOS Core Data. The endpoint message look like this .h #if GTL_BUILT_AS_FRAMEWORK #import "GTL/GTLObject.h" #else #import "GTLObject.h" #endif @class GTLFarmercloudendpointChicken; @class GTLFarmercloudendpointPig; @class GTLFarmercloudendpointCow; // ---------------------------------------------------------------------------- // // GTLFarmercloudendpointFarmer // @interface GTLFarmercloudendpointFarmer :

Core Data with multiple sqlite files

心不动则不痛 提交于 2020-01-02 08:43:41
问题 How may I use Core Data with multiple SQLite files? Each file contains the same structures but the data is retrieved from different locations. I want to be able to switch between these sqlite files at runtime based on application settings. 回答1: Sure; just point the persistent store coordinator (NSPersistentStoreCoordinator) at the different databases, as needed. Persistent store coordinators support addition and removal of stores. On removal, you want to make sure that there are no unsaved

Core Data with multiple sqlite files

◇◆丶佛笑我妖孽 提交于 2020-01-02 08:42:11
问题 How may I use Core Data with multiple SQLite files? Each file contains the same structures but the data is retrieved from different locations. I want to be able to switch between these sqlite files at runtime based on application settings. 回答1: Sure; just point the persistent store coordinator (NSPersistentStoreCoordinator) at the different databases, as needed. Persistent store coordinators support addition and removal of stores. On removal, you want to make sure that there are no unsaved