nsmanagedobject

How do I copy or move an NSManagedObject from one context to another?

I have what I assume is a fairly standard setup, with one scratchpad MOC which is never saved (containing a bunch of objects downloaded from the web) and another permanent MOC which persists objects. When the user selects an object from scratchMOC to add to her library, I want to either 1) remove the object from scratchMOC and insert int...

How to auto-increment reference number persistently when NSManagedObjects created in core-data.

In my application i am using core-data to store information and saving these data to the server using web-connectivity i have to use MySql. Basically what i want to do is to keep track of number of NSManagedObject already created and Whenever i am adding new NSManagedObject, based on that counting it will assign the class a Int_value whi...

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

NSEntityDescription entityForName returning nil

Hi, I did some changes to my model (but I don't want migration yet, so I just remove the application, built clean etc.) However, when I run it on the iPhone or in the simulator, I get the following error: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'executeFetchRequest:error: A fetch request mus...

EXC_BAD_ACCESS NSArray of ManagedObjects (Core Data)

Something strange is going on with my iphone app. I am using Core Data to store data in a SQLite database. The first time after my app starts up I try to read a table to return all of the rows to fill a UITableView with a list of things for the user to select from. If they chose the top item in the list I get a EXC_BAD_ACCESS exception. ...

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

tableview coredata temporary object

Hi, I am using a tableview with data from coredata using nsfetchedresultscontroller. When the view loads i make a new entity using SomeManagedObject *someManagedObject = [NSEntityDescription insertNewObjectForEntityForName:@"SomeManagedObject" inManagedObjectContext:self.managedObjectContext]; This way the new entity appears in my ta...

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

Fill CoreData ManagedObject property based on another object property

I have app that stores tree structure in CoreData. There is an ManagedObject, "Item", and it has attributes: itemId (string) List item title (string) parentId (string) parent (relationship to Item) parentTitle (string) parentId points to another Item object. How do I make property parentTitle to be filled automatically with title...

Using a single view for multiple NSManagedObjects.

So I have a couple properties that are common across several of my Core Data entities. Notes, URL, etc. I have a single view controller for editing this information, and I pass the Entity to it as a NSManagedObject @property (nonatomic, retain) NSManagedObject *editedObject; @property (nonatomic, retain) Thing *thing; @property (nonato...

CoreData: Releasing ManagedObject

I'm using CoreData (with SQLite as the store) in an iOS 4 iPhone application to store data that i initially retrieve from an xml file. My data model contains more than 15 entities and I am concerned about memory consumption since I saw CoreData creating all the NSManagedObject in memory to represent the object graph of my data model. I p...

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

Creating an NSManagedObject with NSDictionary contents

I want to create an NSManagedObject with the contents of a NsDictionary. and Visa Versa. I have a NSDictionary with object and keys that is being brought in from a MYSQL database and stored to the documents directory. I can't find good info for editing a dictionary so I thought I would try NSManaged Object instead. If the Object attri...

CoreData: NSManagedObject does not respond to user defined message

Using CoreData (on an iPhone app) I generated my entity classes from the model and I added some more methods to some ones. It appears that sometimes I get an exception for calling one of those methods. The exception is not random but concerns only some ManagedObject subclass (the others seem to respond correctly). Here is an example of w...

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

How to save changes to NSManagedObject - iPhone 4.0

Hi. I'm using Core Data to fetch news from the memory and I want to modify the unread attribute after the news is read. Code: //method called from within a UITableViewController -(void) didCloseNews:(NSIndexPath*)indexPath{ //get the newsItem - NewsItem subclasses NSManagedObject NewsItem* newsItem = [self.fetchedR...

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

What is an effective way to display a lot of NSManagedObjects in a table view without too much resource overhead?

I'm working on a table view that will display all of a certain type of managed object, and I'm wondering if I should be doing something to prevent faults from firing all the time when the user scrolls and I set up a new cell in the data source? I don't know too much detail about large amounts of managed objects, (several hundred) but I ...

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

How to uniquely identify nsmangedobject with string?

I'm using Core data and region monitoring. The only way to distinguish between monitored regions is with a NSString for identifier. I'd love to use NSManagedObjectID, but I can't get it to work. What I've tried: NSURL *objURL = [managedObjectID URIRepresentation]; NSError *err; NSString *identifier = [NSString stringWithContentsOfURL:m...