nsmanagedobjectcontext

Passing a managedObjectContext through to a UITabBarController's views

左心房为你撑大大i 提交于 2020-01-13 12:16:12
问题 I have an app which is based on the Utility template (where you flip over the view to see another). On the first view there is a login screen, then it flips over to reveal a UITabBar style interface. I'm having trouble working out how to pass the managedObjectContext from the App Delegate (where it is created) all the way through to each of the Tab Bar's views. App Delegate's managedObjectContext get passed to FrontLoginViewController which gets passed to BackViewTabBarViewController .. where

Clearing a context in Core Data: reset vs deleting registered objects?

我的梦境 提交于 2020-01-13 10:46:10
问题 I was looking for posts regarding to this, but I don't fully understand... What is the difference between: [context reset]; and: for (NSManagedObjectID *objId in objectIds) { [context deleteObject:[context objectWithID:objId]]; } Or are they equivalent? Thanks 回答1: Using reset puts the managed object context back to the state it was in when you first created it-- before you had performed any fetches, created any new objects, etc. If you have any managed objects in memory that were fetched

Core Data privateQueue performBlockAndWait deadlock while accessing relationship

不羁岁月 提交于 2020-01-12 03:33:33
问题 This topic has been discussed at many forum, but I am still not able to fully understand how performBlockAndWait actually works. As per my understanding, context.performBlockAndWait(block: () -> Void) will perform the block in its own queue while blocking the caller thread. Documentation says that: You group “standard” messages to send to the context within a block to pass to one of these methods. What are the "standard" messages? It also says that: Setter methods on queue-based managed

NSManagedObject's managedObjectContext property is nil

 ̄綄美尐妖づ 提交于 2020-01-11 08:56:24
问题 I'm trying to create a temporary managed object context, and after a few screens of the user putting in information, I merge that context with the main context (to ensure that there are no "incomplete" objects are inserted). This is how I create my temporary context and how I insert an object in it: if (!self.someManagedObject) { NSManagedObjectModel *model = [NSManagedObjectModel mergedModelFromBundles:@[[NSBundle mainBundle]]]; NSPersistentStoreCoordinator *storeCoordinator = [

core data update in background

偶尔善良 提交于 2020-01-11 07:47:34
问题 I need to basically update my core data in a background thread without blocking UI and save it. After saving should reload table View to view the changes. So for doing this I thought of using dispatch_async( dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ // Add code here to do background processing NSManagedObjectContext *context = [[NSManagedObjectContext alloc] initWithConcurrencyType:NSPrivateQueueConcurrencyType]; self.backgroundManagedObjectContext = context; if(self

NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

时光怂恿深爱的人放手 提交于 2020-01-11 02:38:27
问题 I am having the same issue described at this address http://www.cocoabuilder.com/archive/cocoa/288659-iphone-nsmanagedobjectcontext-save-doesn-crash-but-breaks-on-objc-exception-throw.html I am debugging an application that uses Core Data with multithreading, and I have a breakpoint on objc_exception_throw and it hits this breakpoint in the call to save. (line 2 in code) NSError *error = nil; [self.managedObjectContext save:&error]; if (error) { NSLog(@"Error : %@",error); } I don't have any

NSManagedObjectContext save doesn't crash but breaks on objc_exception_throw

爱⌒轻易说出口 提交于 2020-01-11 02:37:32
问题 I am having the same issue described at this address http://www.cocoabuilder.com/archive/cocoa/288659-iphone-nsmanagedobjectcontext-save-doesn-crash-but-breaks-on-objc-exception-throw.html I am debugging an application that uses Core Data with multithreading, and I have a breakpoint on objc_exception_throw and it hits this breakpoint in the call to save. (line 2 in code) NSError *error = nil; [self.managedObjectContext save:&error]; if (error) { NSLog(@"Error : %@",error); } I don't have any

delete core data managed object with Swift 3

99封情书 提交于 2020-01-07 02:58:27
问题 Swift 3 has migrated my code and changed: context.deleteObject(myManagedObject) to context.delete(myManagedObject) this is compiling fine (XCode 8b3) but at runtime complaining that the context does not have a function/selector delete(managedObject) Here is the runtime error: [NSManagedObjectContext delete:]: unrecognized selector sent to instance My code is very basic: func delete() { let appDel: AppDelegate = UIApplication.shared().delegate as! AppDelegate if let context:

fetchresultscontroller issue or managed object context?

假装没事ソ 提交于 2020-01-06 19:56:33
问题 Reference POST: Core Data - Basic Questions I am able to get the Managed object context from this piece of code. It bring me to another question. I have 2 VIEW CONTROLLERS and 1 NSObject Userlookup (VC) UserlookupSettings(VC) FetchProcessor (NSObject) In sequence, Userlookup vc loads first and has a button to load the Userlookupsettings VC + a textbox and UiButton. When the app is loaded and I hit the SETTINGS uibutton, things work fine... however, when i do the search (FetchProcessor) and

Unable to use Managed Object Context proxy from Interface builder library

末鹿安然 提交于 2020-01-06 14:21:11
问题 I am making a simple mac os x app, in which I will be showing some records in a table view, after retrieving those from local db. I am using core data and NSArrayController proxy for the same and I am trying to achieve it through cocoa-bindings. Now I can easily make it working, by performing this binding in NSArrayController proxy: Proxy: NSArrayController Parameters: Managed Object Context Bind to: App Delegate Model Key Path: self.managedObjectContext but I am trying to use