core-data

How to check if an object is already in the database before saving a new one?

Example: I have a list of friends which I retrieve as XML from a web server. On the device I want to store those friends with an update feature locally. But I only want to store NEW friends. To keep it simple I distinguish them by their first name only (yes thats bad!). As the XML parser walks through the XML, it generates managed objec...

ObjC/Core Data. How can I change the key value of an entity from another NSArrayController?

Hi, I am completely noob in objective-c and I am trying the whole day to find a solution to this problem: I have two entities (Storage and Expenses). In Storage I have an attribute "number". In Expenses I have an attribute "number" and another called "cost" Both entities are linked to tables via cocoa-bindings I have created subclasses...

Multiple Unrelated Entities in one Core Data Model

Hi, I want to have the equivalent of two completely unrelated tables in my database, and for this I have defined two different entities in my Core Data model. Further to this, I have a different ViewController making use of each of these entities and therefore I'm initializing two different fetchedResultsController (one in each ViewC...

Portability of Core Data's SQLite file between OS X and iPhone OS

I have an existing application using Core Data on the iPhone. Occasionally there would be updates to the application's data delivered as updates to the App Store. In my perfect world, building an application to edit the data in the updates with an OS X application and copying the sqlite database to my iPhone app bundle would be a relativ...

iPhone, Core Data, Predicate with "self" problem.

Hi there, I need to reload a Person NSManagedObject before I pass it onto the next View. This is because the fetchedResultsController I'm using is only returning a subset of attributes and I need the full set in the next view. Thus far I'm trying something like: - (void)tableView:(UITableView *)tableViewPassed didSelectRowAtIndexPath...

Can I tell Core Data to use a specific unique ID for an y object when saving it?

Example: I read data from an XML file. This data has unique id elements. I want to store those objects with their original unique id. How would I do that? I figured out I could ask the managed object for it's ID, like this: NSManagedObjectID *moID = [managedObject objectID]; but here the problem is: The XML tells me with the id eleme...

Strategy problem: Retrieving data from XML to update local Core Data DB?

I need some advice how to go about this: 1) I retrieve an XML from a web server. 2) I want to store all the entities (i.e. Friends) from that XML locally on the device, using Core Data. 3) So I parse the XML and make an Managed Object for every Friend in that XML 4) But I want to make sure that I don't add one Friend multiple times i...

Can I create manually an instance of an Core Data Entity class for temporary usage?

I have an custom class for an Core Data entity, called 'Friends'. As I am parsing an XML File, I need to create temporary instances to hold temporary data, without using Core Data at this point. So there are two options: A) create an NSMutableDictionary to hold the temporary data while parsing an "object" from the XML. B) use the class...

iPhone CoreData application crashing for first time start

I wrote iPhone application using core data. When I run application in simulator, its crashing with following error: 2010-02-12 17:24:22.359 CrData[46122:4503] Unresolved error Error Domain=NSCocoaErrorDomain Code=513 UserInfo=0x3f484e0 "Operation could not be completed. (Cocoa error 513.)", { NSUnderlyingException = Error validating...

Fastest way to check if an object exists in Core Data or not?

I want to see if an object is persistet in Core Data or not. For example, I have Friends in Core Data, and I identify them by firstName. I can query core data to see if "George" is known. If the result set array contains more than zero objects, I know George is there. But Core Data loads the whole thing into memory, and I actually just w...

Core Data on device vs simulator

I have a simple Core Data application, with a table view and a drill down view. When I build and run in the simulator, all of the data in my database loads and the table view/drill down views function properly. When I build and deploy to a device, my application only loads a small subset of the data (a few sections, A - C). I have no w...

Can I clear the Managed Object Context?

Problem: I am doing a really big import where I parse an XML file. For every 10 parsed managed objects, I want to save the Managed Object Context and get rid of those 10 objects in memory, so that I have never more than 10 objects in memory at a time. After saving it, how could I clear the context so that all the objects go away from me...

Many-to-many relationship with optional value?

I have a many-to-many relationship between two tables: Order and Item. I need to save an extra information on this relationship, the quantity. So, I have to create an extra table in my model .xcdatamodel? In the following schema, both orderItems are to-many relationship to OrderItem table. order & item are inverse relationship. Orde...

CoreData unique objects by attribute

Hello, I have a graph with one kind of object called Message. A message could have childs so the graph is a tree. Each object on the graph contains an attribute value; that's a sort of UUID (globally unique) so the store cannot contains multiple messages with the same UUID (this uuid is a string taken from message data so I can't replace...

Keeping iPhone application in sync with GWT application.

Hi, I'm working on an iPhone application that should work in offline and online modes. In it's online mode it's supposed to feed all the information the user enters to a webservice backed by GWT/GAE. In it's offline mode it's supposed to store the information locally, and when connection is available sync it up to the web service. Curre...

Removing and adding persistent stores to a core data application

I'm using core data on an iPhone application. I have multiple persisntent stores that I'm switching from one to another so that only one of the stores can be active at the time. I have one managed object context and the different persistent stores are similar in data format (sqlite) and share the same managed object model. I'm importing...

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

Is it possible to access the raw data in Core Data for a Transformable attribute

I have an image field of type transformable and a typical ImageToDataTransformer class. 99% of the time that's perfect and great shortcut, but just occasionally I find myself transforming the managed object back to NSData (knowing that if it wasn't for the ImageToDataTransformer I would have got NSData in the first place). As these oper...

Cocoa: Core Data relationships not working

I have a basic Core data model like this: Class -Class Name (string) Relationship: HasDetails (to many) -to Details Details -Number (int) -Name (string) Relationship: IsPartOfClass -to Class I have two table views, one for "Class" and one for "Details" and have all the bindings set up, however, when I add a new object to Details ...

How to programmatically retrieve table selection and table row for Core Data app?

I'm trying to make a Core Data app in which when you select one "Player" in a TableView, and a list of all teammates appears in a second tableView, with a column for how many times those two players have played on the same "Team" (another entity). This has got me completely stuck, because while I know how to fill up a table from a norma...