iphonecoredatarecipes

managedObjectModel is nil (Cannot create an NSPersistentStoreCoordinator with a nil model)

那年仲夏 提交于 2019-12-22 15:25:12
问题 I have this special case scenario, where in my app works perfectly fine for some time and crashes inconsistently after some time. The error that i get during the crash is "Cannot create an NSPersistentStoreCoordinator with a nil model" . I tried debugging my app and found that the managedObjectModel is returning NULL sometimes. To add fuel to the fire, this scenario is not at all consistent. For some time the managedObjectModel is fine. But, suddenly it returns NULL ... Here is the code that

Why does Core Data initialization fail when I attempt to do it at these points?

帅比萌擦擦* 提交于 2019-12-20 02:49:22
问题 I see how to solve the problem but it bothers me that I don't understand why this doesn't work. I have a UIViewController subclass that uses Core Data, so it needs the NSManagedObjectContext. The controller is loaded from a nib file where it's placed under a navigation controller which is inside a tab controller. I tried doing this in initWithCoder and viewDidLoad and for some reason it doesn't work: MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate];

Method for import initial data with coredata

Deadly 提交于 2019-12-19 10:24:14
问题 I meet a problem when I import data in an ios app. The data is stored with coredata. I was trying to import the data with a button. After it is clicked, the data, which is firstly stored in a txt file in JSON format will be stored in the sqllite file. My question is this, it is very slow to import such amount of data and it is not friendly for user to click button or wait to import the initial data. Is there a better way to import data? Thanks. 回答1: It depends. For example you could just

managedObjectModel is nil (Cannot create an NSPersistentStoreCoordinator with a nil model)

爷,独闯天下 提交于 2019-12-06 06:46:36
I have this special case scenario, where in my app works perfectly fine for some time and crashes inconsistently after some time. The error that i get during the crash is "Cannot create an NSPersistentStoreCoordinator with a nil model" . I tried debugging my app and found that the managedObjectModel is returning NULL sometimes. To add fuel to the fire, this scenario is not at all consistent. For some time the managedObjectModel is fine. But, suddenly it returns NULL ... Here is the code that I am using to create a managed object model. - (NSManagedObjectModel *)managedObjectModel { if

iOS app - architecture/sample for synchronizing CoreData against Web-Service

久未见 提交于 2019-12-04 21:31:13
问题 I am looking for either a sample app or a more architectural discussion to build an app, which maintains a local persistent store (CoreData) and keeps it sync against a Web-Service like Flickr. In my case it is Salesforce, but the pattern should be similar to many apps for Flickr, Twitter, IMAP and so on. Sample questions: where are the best points to invoke the syncing? what are proven datastructures to maintain local changes - maintain a "changed" BOOL in the local store for every unsynched

iOS app - architecture/sample for synchronizing CoreData against Web-Service

混江龙づ霸主 提交于 2019-12-03 13:45:57
I am looking for either a sample app or a more architectural discussion to build an app, which maintains a local persistent store (CoreData) and keeps it sync against a Web-Service like Flickr. In my case it is Salesforce, but the pattern should be similar to many apps for Flickr, Twitter, IMAP and so on. Sample questions: where are the best points to invoke the syncing? what are proven datastructures to maintain local changes - maintain a "changed" BOOL in the local store for every unsynched change; I would prefer a field level flag against a record level flag)? Of course I have to optimize

Why does Core Data initialization fail when I attempt to do it at these points?

梦想与她 提交于 2019-12-01 21:02:29
I see how to solve the problem but it bothers me that I don't understand why this doesn't work. I have a UIViewController subclass that uses Core Data, so it needs the NSManagedObjectContext. The controller is loaded from a nib file where it's placed under a navigation controller which is inside a tab controller. I tried doing this in initWithCoder and viewDidLoad and for some reason it doesn't work: MyAppDelegate *appDelegate = (MyAppDelegate *)[[UIApplication sharedApplication] delegate]; self.managedObjectContext = [[appDelegate managedObjectContext] retain]; For some reason

How to delete row in table view core Data. Swift 3

微笑、不失礼 提交于 2019-11-29 13:01:26
I been researching how to delete a row from a table view which the data is in Core Data. I can't find anything online that would help me with my code. Im really new with Core Data so I don't really understand much of it. Thanks in advance This is my Code override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) guard let appDelegate = UIApplication.shared.delegate as? AppDelegate else { return} let managedContext = appDelegate.persistentContainer.viewContext let fetchRequest = NSFetchRequest<NSManagedObject>(entityName: "OfficialPT") fetchRequest.sortDescriptors =