nsmanagedobject

Cross-model relationships in NSManagedObjectModel from merged models?

Is it possible to model relationships between entities that are defined in separate NSManagedObjectModels if the entities are always used within an NSManagedObjectModel that is created by merging the relevant models? For example, say model 1 defines an entity Foo with relationship (one-to-one) toBar and that model 2 defines an entity Ba...

Abstracting NSManagedObject and NSDictionary

In my project I have some objects that I show from a server, lets call them Foo's. When I get my Foo feed, I parse them into a NSMutableDictionary subclass called RemoteFoo, and pass these RemoteFoo objects all around the app to display data. If the user ends up wanting to download a RemoteFoo, I then create a core-data NSManagedObject...

Multi-property "transactions" in Core Data / NSManagedObject / NSFetchedResultsController?

Hi, Is it possible to set multiple properties of an NSManagedObject and have the NSFetchedResultsController call controllerDidChangeContent: only once? In other words, is it possible to say something like: [managedObject beginChanges]; [managedObject setPropertyA:@"Foo"]; [managedObject setPropertyB:@"Bar"]; [managedObject commitChang...

Does the performance of saving a ManagedObjectContext depend on the number of contained (unchanged) objects?

A general CoreData/SQLite question Is there a significant difference between these two scenarios when saving a NSManagedObjectContext using an SQLite store: After adding/changing/deleting one object in a NSManagedObjectContext containing 10 otherwise unchanged NSManagedObjects After adding/changing/deleting one object in a NSManagedOb...

Core Data Context "dirty": MOC save crashes app

Hi there, Fairly new to iPhone dev. My app uses Core Data, and at one point I'm attempting to save some data during an NSFetchedResultsControllerDelegate method: - (void)controller:(NSFetchedResultsController *)controller didChangeObject:(id)anObject atIndexPath:(NSIndexPath *)indexPath forChangeType:(NSFetchedResultsChangeType)type ...

Adding string to a tableview iphone sdk

hi, i created a new project with a tableview already done by default with the add button which add dates. But the project is im not familiar with the nsmanagedobject thing. I want to add specific string to this not dates. thx for help!! NSManagedObjectContext *context = [fetchedResultsController managedObjectContext]; NSEntityDescriptio...

Core data images from desktop to iphone

I built a simple mac data entry tool I use with an iPhone application. I've recently added thumbnail which I added via an Image Well using simple bindings. Its a transformable data type which seems to work fine. The iPhone application however won't show the images. The attribute isn't null but I can't get an image to appear. The followi...

NSManagedObject: isUpdated and isInserted

Hello, I keep track of my 'objects' using the isUpdated instance method of NSManagedObject Class. When I'm modifying an exisiting object, it works. If I create a new object using for example: [NSEntityDescription insertNewObjectForEntityForName:@"Entity" inManagedObjectContext:managedObjectContext] I can't use the isUpdated, I have...

Is it bad to modify Core Data properties in validateForUpdate:?

I am using Core Data for an iPhone application. I have a property isChangedFromOriginal that defines if the data (for several fields - if one is changed it is the same as if all were changed) was changed from a preloaded standard. I am planning to create a subclass of NSManagedObject and perform the checks in ValidateForUpdate:, howe...

Disable persistence of a given NSManagedObject until user hits a button?

I have an NSManagedObject with attributes that a user can edit with a view. The view is populated with the values from the object, the user can edit the values, and the values are written back to the object. I want the user to explicitly tap a save or cancel button to commit or undo the changes. The problem is that the view is in a UI...

NSUndoManager undo Not Working With Core Data

Hi there, I am trying to create an iPhone application where the user can add entries. When he presses a new entry, a box will popup asking him for some information. Then he can either press "Cancel" or "Save" to discard the data or save it to disk. For saving, I am using the Core Data framework, which works pretty well. However, I cann...

CoreData and NSXMLParser

Hi Stackoverflow friends, I am parsing an XML file of the network using NSXMLParser after I got the Data from NSURLConnection. The XML has many "items" and each item contains 1 category. In the CoreData module i have an Item entity with a relationship to one Category. While parsing the XML file and hitting the message parser:didStartEl...

Core Data: editing object from detail view

I'm just starting out with Core Data and I have an iPhone Core Data project set up in a master-detail view system. The master view contains items, and the detail view lets you edit the properties of the selected item. I'm looking for the best options in order to implement the editing. Would I pass along the NSManagedObjectContext to the...

Core Data Automatic Update Inquery

I have a question concerning Core Data and how, if at all, Entities get updated automatically. Basically, let's say I fetch some data X. X has an inverse to-many relationship with Y. Then a method get's called to update an attribute in X. Does one have to fetch the data again? or will X automatically get the updated data? If this is no...

iPhones SDK: Setting a relationship property object using core data?

I'm using core data in my app. I have two entities that are related: EntityA and EntityB. EntityA has a property of type "relationship" with EntityB. In addition, both of these entities are defined classes (not the default NSManagedObject). I'm inserting a new object into my data like this: EntityA *newEntityA = [NSEntityDescription ins...

How to retrieve stored reference to an NSManagedObject subclass?

Hi! I have a NSManagedObject subclass named Tour. I stored the reference to it using this code: prefs = [NSUserDefaults standardUserDefaults]; NSURL *myURL = [[myTour objectID] URIRepresentation]; NSData *uriData = [NSKeyedArchiver archivedDataWithRootObject:myURL]; [prefs setObject:uriData forKey:@"tour"]; Now I want to retrie...

Core Data NSPredicate to filter results

I have a NSManagedObject that contains a bID and a pID. Within the set of NSManagedObjects, I only want a subset returned and I'm struggling to find the correct NSPredicate or way to get what I need out of Core Data. Here's my full list: bid pid 41 0 42 41 43 0 44 0 47 41 48 0 49 0 50 43 There is a paren...

iPhone CoreData: How can I track/observe all changes within a subgraph?

I have a NSManagedObjectContext in which I have a number of subclasses of NSManagedObjects such that some are containers for others. What I'd like to do is watch a top-level object to be notified of any changes to any of its properties, associations, or the properties/associations of any of the objects it contains. Using the context's ...

NSManagedObject relationship undo

I have a NSManagedObject ObjA that has a many-to-many relationship with another NSManagedObject ObjB. I initialize it with [NSEntityDescription insertNewObjectForEntityForName:@"ObjA" inManagedObjectContext:app.context]; When I perform undo without performing save - the object is not added to the persistent store. But - when I add an i...

NSManagedObjectContext losing data after 2nd save

I have a class called DataRequest, which handles downloading data from a web service via NSURLRequest, parsing the results and stuffing data into a NSManagedObject, and saving it. It contains the fowlling: @property (nonatomic, retain) id DataControllerProtocol dataController; I also have a class called DataController, which encapsul...