nsmanagedobjectcontext

Illegal relationship between objects in different contexts: but I only have one context?

I get the following error: 'NSInvalidArgumentException', reason: 'Illegal attempt to establish a relationship 'condition' between objects in different contexts when running my iphone app. The relevant part of my model looks like this: AssessmentTree -has one TreeCrown TreeCrown -has one TreeCrownCondition -has one Assessme...

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

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 ([[...

[iphone] NSManagedObjectContext issues

Hi there I've set up my project with the "use coredata" option set. XCode obviously set all this up for me automatically, and now I have these lines in the app delegate header file: @interface GFree2AppDelegate : NSObject <UIApplicationDelegate> { UIWindow *window; GFree2ViewController *viewController; UINavigationControll...

Why can't I get the context from the delegate with this code?

I get an annoyingly vague error from the following code: GFree2AppDelegate *delegate = [[UIApplication sharedApplication] delegate]; context = [delegate managedObjectContext]; context is defined as a NSManagedObjectContext in the .h file and is the same in the delegate. All the right files seem to be included (except for <CoreData/Cor...

how do you create a NSManagedObjectContext

In core data for the iPhone, I was getting all sorts of errors trying to save data to a NSManagedObjectContext. I believe that my issues were all to do with me using a `NSManagedObjectContext' that was being used in multiple threads. So I wanted to create a new NSManagedObjectContext and try that, but I cannot find the example code to ...

Bizarre CoreData problem and even more bizarre solution. Any idea why?

I'm a pretty comfortable CoreData user. I had a problem that was absolutely killing me, figured out what was going wrong and have NO CLUE why it was causing the problems I was seeing. Can anyone explain this? Okay, we have a main MOC that does most the 'read-only' data work and handles simple write operations. When we're about to do a b...

Editing Core Data row from entity linked to managedObjectContext via relationship

Hi All I need to edit a row of data in an Entity that has a relationship with my main Entity from my fetchedResultsController, in this case "theUser" being an instance of my User entity. I basically need to edit one of the CannedMessage rows that already exist and save it. I can access the "Messages" fine as you see below, but am unsur...

Having trouble copying data to a mutable array

I keep getting the error "Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[MainViewController minimalFormInContext:]: unrecognized selector sent to class" from this line of code: NSLog(@"Accessing specific mine entities"); NSEntityDescription *entity = [NSEntityDescription entityForName:@"Mine" inMa...

fetchresultscontroller issue or managed object context??

Reference POST: http://stackoverflow.com/questions/3681003/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 a...

What's an effective CoreData context/coordinator strategy for this common application pattern?

I have a common application pattern: user enters data in the main view controller, then views it in a table in a modal view controller, where rows can be deleted or modified. I was following the general design strategy from the Stanford iPhone course, but somewhere things went off the rails and all I've been getting is SIGABRT's and exc...

NSFetchedResultsController for same managed object (table)

Hello, I would like to know if I can do this VIEW 1: use NSFetchedResultsController on TABLEA to retrieve the data, display in a table view and take actions to save it NSFetchedResultsController *aFetchedResultsController = [[NSFetchedResultsController alloc] initWithFetchRequest:fetchRequest managedObjectContext:referringObject ...

iPhone: transfer objects between NSManagedObjectContext objects?

I currently have an NSManagedObjectContext containing 5 Video Objects displayed in a table view. When a user selects a row, I'm going to push in a new view controller to display object details, and give the user the option to 'add Video to favorites'. To do this, I want to create a new NSManagedObjectContext, assign the selected Video ...

ManagedObjectContext seems to change after save and can't be changed by some other ViewController

Hi all I have a MOC created in my AppDelegate class. I have a MOC property in my RootView which is set by the AppDelegate with something like: rootView.managedObjectContext = self.managedObjectContext; This rootView creates at some time a ModalView and sets there a MOC property also by the same way. Everything works fine. I can crea...

What am I doing wrong with NSManagedObjectContext dependency injection?

I am trying to use NSManagedObjectContext dependency injection as recommended by Marcus Zarra -- I'm creating an M.O.C. in my AppDelegate and passing it as a retained property to each of my view controllers. Generally this seems to work well, but in a modal table view controller that presents data via an NSFetchedResultsController, I on...

CoreData could not fulfill a fault after MOC refreshed - how to solve?

Hi guys I'm new to iphone development and have this problem with Core Data. At the moment my app works as follows: I'm executing a fetch from Core Data and display my list of objects in TableView Detaching new thread, create new MOC for it, as advised, Getting xml, parse it, then clear Core Data and fill it with new data from xml Sav...

How to get all entries of a NSFetchedResultsController/NSManagedObjectContext ?

Hi I have a nice working iphone app that works with core data. I use a NSFetchedResultsController/NSManagedObjectContext as described in various tutorials. Now I want to extends my app and add some more features. The problem I need to build up an array with objects that have informations from my data. I somehow need to get a list of a...

Core Data Saving to Database not Working

Hi, I'm a first time Core Data user/learner for iPhone, I thought that [managedObjectContext save:$error] was used to save changes to the Persistant Store. But when I reload and call NSFetch, the objects are still there. Any ideas why? for (int i ; i < [mutableFetchResults count];i++) { NSManagedObject *toDelete = [mutableFetchResu...

NSManagedObjectContext CoreData device / simulator differences

Hi, I'm relatively new to iPhone dev and have been trying to build an application to understand how CoreData works. I'm trying to implement some functionality that will allow me to detect if anything has been persisted to store and if so - give the user the option to delete those objects. I wondered if there are timing issues that nee...

Passing a managedObjectContext through to a UITabBarController's views

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

What are all the steps should be taken while shifting a core data programs location?

Hi friends, I did a program using core data and saved it in my desktop. The entities, relationships are available in .xcdatamodel file. Then i copied my entire program into some other folder in disk and erased the original file placed in desktop. Now the copied program did not work. The managed objects are null. What changes must i do ...