nsmanagedobjectcontext

Iphone - managedobjectcontext not properly saving

Any idea why //should save the object context. NSError *error; if (![managedObjectContext save:&error]) { NSLog(@"SAVE ERROR"); } when implemented in a view controller(accessed via a drill down tableview) won't properly save the information? I am passing the moc from the beginning (rootview hands off to tableview, tableview r...

Core-Data: NSLog output Does Not Show "Fields"

Hello, I don't understand the output of NSLog for the array returned by a NSFetchRequest. I'm reading my database and placing the contents in an array, looping through the array and then outputting the contents with NSLog. I don't quite understand the output in the log file. Code below: -(void)createXMLFeed{ //Fetch details from ...

Using an NSManagedObject subclass entity in both an in-memory store, and a SQLite store

I would like to use a single NSManagedObject subclass to represent an item. However, much of the time, the items I will be representing are fleeting, and are not to be saved to the persistent store. It seems like an in-memory store would be the correct setup. However a few times the user can choose to 'save' an item, and thus I would th...

Is it OK to have multiple NSManagedObjectContext instances per thread?

You have to have one per thread, but beyond that ... should you have more? Is it harmful to have more? For instance, I'm tempted to build my app around having one NSManagedObjectContext per tab, handling the subset of the overall persistent store that appears on that particular tab. That way, I can have the tab GUI listen to notificata...

Why am I getting a different instance of a ViewController than the one I pushed onto the navigationController?

Why would I be getting a different instance of HistoryViewController than the one I instantiated and pushed onto the navigationController? The different instance created doesn't have any of the properties I've set. ProfileHomeViewController.m HistoryViewController *historyViewController = nil; historyViewController = [[HistoryViewCon...

How to make/use temporary NSManagedObjects?

Simple, common pattern I can't find in Apple's docs: Load a coredata store Download new data, creating objects in memory Save some of the new data to the store (usually "only the new bits / bits that haven't changed") Instead, I can find these alternatives, none of which are correct: Don't create objects in memory (well, this means...

CoreData: Fetching an Object from an unsaved Context

Hi, after I insert a ManagedObject into a context I'd like to fetch it later but before saving the context (I'd save after all objects are inserted). It appears that querying the context later with a fetch concerning those objects returns nothing if the context wasn't previously saved. Is there a way to save only in the end ?(I guess i ...

How to get the ID of an object saved to Core Data's managed object context?

I have this code: NSEntityDescription *userEntity = [[[engine managedObjectModel] entitiesByName] objectForKey:@"User"]; User *user = [[User alloc] initWithEntity:userEntity insertIntoManagedObjectContext:[engine managedObjectContext]]; and I want to know the id of the object inserted to the managed object context. How can i get that?...

MapKit How to pass managedObject from mapView to mapDetailView

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.man...

CoreData and Shared ManagedobjectContext in TabBar iphone app.

I a, working on coredata iphone TabBar app and passing appdelegate managedObjectContext to all the views and subviews.At some instance i need to create new record for entity A and while entity A didn't saved by the user i need to create another entity B by using the same shared context. Now, my problem is if i save the context for entity...

Sharing Non-Persistent Objects Between Contexts in Core Data?

I was wondering if there is a way to share an NSManagedObject between two or more NSManagedObjectContext objects running in the same thread. I have the following problem: I have one main context shared through all my code in the application and several different contexts that are created for each remote fetch request that I issue. (I c...

NSManagedObjectContext: autoupdate or not?

Hi everybody, I need to understand something about NSManagedObjectContext update. I have a UISplitView with a UITableViewController on the RootView and a UIViewController on the Detail View. When I tap in a row with data, I load some data into labels and a UITextView where I can update that field: - (void)textViewDidEndEditing:(UITextVi...

Add an instance of NSManagedObject to NSManagedObjectContext ok, updating the same instance failed

I am using core data in my iPhone app. I have created a simple class Friend, which derives from NSManagedObject and which uses the following property: @property (nonatomic, retain) NSString *name; I am able to add and delete instances of this class to my context and my changes are persistent also. Now I want to update/modify a Friend-...

CoreData the save method is not working

Im a creating an app for my iPhone using coredata. I have a viewcontroller with an object i want to save that object to my FavoriteViewController. By clicking a button favorite I want my object to be save into the managedObjectContext but I'm getting the following error: Terminating app due to uncaught exception 'NSInternalInconsisten...

Core Data: Error if deleting unsaved object

I have some trouble with a core data project. I have a NSArrayController with NSManagedObjects in it, and + / - buttons. If i delete a object in the row after the file has been saved it works perfectly, but if I add a new object, and immediately delete it again (without changing any of the default values), i get an error: Serious appli...

Avoiding infinite recursion synching between multiple NSManagedObjectContexts

The setup: I have two managed contexts setup (on an iPhone application). A main context that I use for most queries and a background context I use for long running operations that I want to happen in the background. I've setup notifications for NSManagedObjectContextDidSaveNotification against each managed object context. In response t...

How do I trigger a reload in an NSFetchedResultsController without changing the fetched object?

In my iPhone app, I have an NSFetchedResultsController showing User objects in a UITableView. The User Objects have 0-many Log objects. A summary of the Log objects are shown together with their User object in the UITableView. My app uses a tab bar, so user input in the logging tab require that the user tab's NSFetchedResultsController ...

Multiple layers of MOC merges...CoreData veterans, what do you think?

Original question has been answered. Update addresses related question raised in comments. Original post: I am using the MOC save method used in Apple's CoreDataBooks. However, I seem to have use for two layers of MOC merging (three MOCs where the 3rd merges with the 2nd and then the 2nd merges with 1st). First, I have a tableview (Cl...

iPhone managedobject delete crashing.

Hi, I try to delete some managedobjects by calling in a for loop [managedObject delete]; and at of the loop, I call [managedObjectContext save:nil]; At the above line, the app crashes and goes nowhere from there. Any ideas? Thanks ...

COMPILED Core Data Managed Object Model: Get maximum info from it and its corresponding database

Hi everybody, I am a novice in Objective-C; and I could not find any solution in my Books or internet. My question: What are the most efficient and fastest ways to use already compiled .mom and SQLite db without having the source codes? Details: I am trying to connect my small app to the database of another application and use (read-in...