nsmanagedobjectcontext

MapKit How to pass managedObject from mapView to mapDetailView

帅比萌擦擦* 提交于 2019-12-08 04:19:59
问题 I am trying to pass a managedObject from a mapView with multiple annotation to a mapDetailView with only one annotation of the managedObject passed. This works great in a tableView to mapDetaiView. Any help would be appreciated. My code ... - (void)viewDidLoad { [super viewDidLoad]; if (self.managedObjectContext == nil) { self.managedObjectContext = [(CrossroadsTreasuresAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; } // setup the mapView [mapView

I got fault when I fetched my data from NSManagedObjectContext

点点圈 提交于 2019-12-07 14:48:22
问题 I run my app and then fetched my data. Data is ok. When I run second time I got fault for my old values. What is wrong? - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSEntityDescription *entity = [NSEntityDescription entityForName:@"Test" inManagedObjectContext:[self managedObjectContext]]; for (int i =0; i<2; i++) { Test *test = [[[Test alloc] initWithEntity:entity insertIntoManagedObjectContext:[self managedObjectContext]]

MapKit How to pass managedObject from mapView to mapDetailView

若如初见. 提交于 2019-12-07 09:57:30
I am trying to pass a managedObject from a mapView with multiple annotation to a mapDetailView with only one annotation of the managedObject passed. This works great in a tableView to mapDetaiView. Any help would be appreciated. My code ... - (void)viewDidLoad { [super viewDidLoad]; if (self.managedObjectContext == nil) { self.managedObjectContext = [(CrossroadsTreasuresAppDelegate *)[[UIApplication sharedApplication] delegate] managedObjectContext]; } // setup the mapView [mapView removeAnnotations:mapView.annotations]; [mapView setMapType:MKMapTypeStandard]; [mapView setZoomEnabled:YES];

Does an NSManagedObject retain its NSManagedObjectContext?

谁都会走 提交于 2019-12-07 07:13:16
问题 NSManagedObject provides access to its NSManagedObjectContext, but does it retain it? According to "Passing Around a NSManagedObjectContext on iOS" by Marcus Zarra, "The NSManagedObject retains a reference to its NSManagedObjectContext internally and we can access it." How does Zarra know this and is he correct? I'm asking because I want to know if the NSManagedObjectContext will be dealloc 'ed in the tearDown method below. (I'm using CocoaPlant.) #import <SenTestingKit/SenTestingKit.h>

Duplication of entity when change made by a child ManagedObjectContext is pushed (saved) to its parent

廉价感情. 提交于 2019-12-07 05:49:26
问题 I expect (hope even) that this will be a stupid question, but after wrestling for many hours with this problem I need some insight. My iOS 5.1 app uses nested MOCs, having a PrivateQueueConcurrency child MOC, call it MOC-Child, whose parent is a MainQueueConcurrency MOC, call it MOC-Parent. MOC-Parent backs a table view that displays its entities. MOC-Child is used by a parser, which runs asynchronously on a non-main thread, to create new entities that correspond to XML entity-descriptions

Crashing on saving a managedObjectContext, with 'NSInvalidArgumentException', but only sporadically

女生的网名这么多〃 提交于 2019-12-07 02:53:19
问题 I keep getting crashes from a save: command on a managedObjectContext. It doesn't even fulfill the NSLog statement so I don't see the unresolved error statement, so I can't figure out what the problem might be. It doesn't happen every time, but only sporadically. Here's the code (which basically wants to increment a counter): if ([[managedObject valueForKey:@"canSee"]boolValue]){ int read = [[managedObject valueForKey:@"timesRead"] intValue] +1; [managedObject setValue:[NSNumber numberWithInt

Why does Core Data take so long to save an object?

雨燕双飞 提交于 2019-12-06 16:09:12
I have a simple method in my entity category that adds custom methods to my subclassed NSManagedObject classes (which I don't touch because of automatic subclassing generating). I have this method that deletes an object from the MOC and saves the context. + (void)deleteWishlist:(Wishlist *)wishlist inManagedObjectContext:(NSManagedObjectContext *)context { [context deleteObject:wishlist]; NSError *error; if(![context save:&error]) { NSLog(@"%@", error); } else { NSLog(@"Delete successful"); } } I invoke this from one of my view controllers as so: - (void)deleteWishlist:(Wishlist *)wishlist {

Trying to implement master-child Managed Object Context when doing mass delete in Core Data

女生的网名这么多〃 提交于 2019-12-06 15:36:53
I am working on a project where I am doing a mass delete of a number of NSManagedObjects (MO) that I retrieve from Core Data. When I iterate through this collection of MO's, I am also retrieving OTHER MO's by calling a fetch method DURING the iteration of the initial collection of MO's. If during this iteration process, an object is found from the fetch request, the MO is deleted. I realize that this is a poor design of the architecture, as these MO's should in fact be having inverse relationships with one another, and therefore via a cascade delete rule, all of these objects would easily be

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

醉酒当歌 提交于 2019-12-06 15:31:44
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 app are operating with them. Both contexts are "siblings", they are not parent and child. This is

Unable to pass NSManagedObjectContext to my view controller

雨燕双飞 提交于 2019-12-06 13:44:48
问题 Ok, I may be in well over my head here, but suspect I am missing something quite fundamental. I have searched on stack and other forums for help on finding a solution. I've tried all the solutions I have found but none work for my situation and I cannot see what I am missing. I have created a CoreData app. All works fine in reading and writing data to the CoreData store using NSManagedObjectContext within my appDelegate. I have checked to see if the NSManagedObjectContext is set in my