core-data

iphone core data loop array and save each

I have a core data model with two tables (meal and ingredients). I am trying to save ONE meal with MANY ingredients. I have the code below which loops through an array of ingredients. I'm trying to save it, but I cannot redeclare the "entity" below. How do I do it? I've tried releasing it, but that didn't work! Thanks for any help. for...

NSFetchedResultsController didn't return data

Hello! I get stuck in some problem and after 2 days of seeking I've found solution but didn't get idea why does it work. First, I'm initialized NSFetchedResultsController using following code (it look like a lot of automatically generated): - (NSFetchedResultsController *)fetchedResultsController { if (fetchedResultsController != nil...

Unexpected key-value behavior in a Core Data Context

If I create an array of strings (via key-value coding) containing the names of a Managed Object entity's attributes which are stored in the App Delegate the first time, I get an array of NSStrings without any problems. If I subsequently make the same call later from the same entry point in code, that same collection becomes an array of N...

iPhone - is there any way to look at the core data store for a live app?

I've got a live app on the app store that's producing some strange results when the user upgrades versions that I can't reproduce in my dev environment. Does anyone know of a way to inspect the core data store of a live iPhone app? ...

Implementing Tagging using Core Data on the iPhone

I have an application that uses CoreData and I'm trying to figure out the best way to implement tagging and filtering by tag. For my purposes, if I was doing this in raw SQLite I would only need three tables, tags, item_tags and of course my items table. Then filtering would be as simple as joining between the three tables where only ite...

Core Data migration failing with error: Failed to save new store after first pass of migration

In the past I had already implemented successfully automatic migration from version 1 of my data model to version 2. Now, using SDK 3.1.3, migrating from version 2 to version 3 fails with the following error: Unresolved error Error Domain=NSCocoaErrorDomain Code=134110 UserInfo=0x5363360 "Operation could not be completed. (Cocoa error 1...

Apples Core Data iPhone Recipes Example Question

Why does Apples Core Data iPhone Recipes Example use a separate entity for called Image linked to the Recipe Entity via a one to one Relationship to store the recipes image. Why not just have an "image" attribute in the Recipe Entity? Many Thanks ...

nsfetchedresultscontroller with empty sections

I have a database of People and pets, with a one to many relationship Person Pet Name Name Pet <----->> Owner I am using a UITableView backed by Core data and a nsfetchedresultscontroller to display the list of pets, grouped into sections by the owner. NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]...

[NSFetchedResultsController sections] returns nil?

Hi Everyone, I am trying to resolve this for days at this stage and I'm hoping you can help. I have two ViewControllers which query two different tables from the same database using Core Data. The first ViewController is opened with the app and displays fine. The second is called from within the first ViewController, using a pretty sta...

iPhone application update (using Core Data on Sqlite)

I have an app which is using Core Data on Sqlite, Now I have a update which has some DB structure changes say adding a new table I know when an app get updated, it updates the app binary only, nothing on document directory will be changed. When the app gets updated and launchs at the first time and run [[NSPersistentStoreCoordinator a...

IPhone CoreData: How should I relate many child entities to thier parents

I am trying to import data from a database that uses primary key / foreign key relations to a core data database in Xcode. I have code that creates hundreds of child entities in a managed object context: Each child has an ID that corresponds to a parent. child1 parentID = 3 child2 parentID = 17 child3 parentID = 17 ... childn...

Deploying App With Dummy/Initial Data

I have a Core Data based application that stores hierarchal data displayed using a series of UITableViews. To illustrate my app functionality to the user I would like to pre-populate my database/app with some dummy values. This data would be available upon installation on the user's iPhone/iPod Touch. What is the best way to achieve t...

Core Data - 'calculated' attributes

I have two entities: A and B A has two properties from and to, both pointing to the B entity. B as a fetched property to A with predicate from == $FETCH_SOURCE or to = $FETCH_SOURCE -- (from) -> A -- (to) -> B <- (As) -- In my application I select a certain B instance, and then show all of its A instances. Now, in my tab...

How can I duplicate, or copy a Core Data Managed Object?

I have a managed object ("A") that contains various attributes and types of relationships, and its relationships also have their own attributes & relationships. What I would like to do is to "copy" or "duplicate" the entire object graph rooted at object "A", and thus creating a new object "B" that is very similar to "A". To be more spec...

Core Data and many Entity

I'm newbie and I must save "Ranking" and "Level" of user. I create file Ranking.xcdatamodel for save "Ranking" with entity name Ranking (property is Rank, Name) I can save and show it. But when I create entity Level (property is CurrentLevel) my program is crash and show this message: Unresolved error Error Domain=NSCocoaErrorDoma...

Iterate through NSManagedObjectContext objects?

I want to iterate through all of the objects in my NSManagedObjectContext, and update them manually. Then, every managed object should be updated. What's the best way to do this? ...

NSManagedObjectContext returns YES for hasChanges when there are none

I created a separate NSManagedObjectContext on a separate thread to perform some store maintenance. However, I have noticed that the context returns YES for hasChanges as soon as a managed object in it is even referenced e.g. NSString *name = managedObject.name; This context is created and used exclusively in 1 method. Why is it retur...

No performance gain with -setfetchbatchsize on NSfetchedresultscontroller

Hi: I tried to gain performance by setting -setfetchbatchsize to 20 on NSFetchedResultsController with about 2k core data entries. But I can't recognize any changes in retrieval time by using -setfetchbatchsize. It is as slow as before on the iPhone... Any experiences? Edit: I just found a bug report with a similar issue: http://openra...

Assign TableView column binding to a specific core-data object in to-many related entity based on separate attribute

How would I assign a column of a TableView to be a specific entry in a Core Data entity that is linked to the NSArrayController via a to-many relationship? For example Entity: MovieEntity Attributes: title(NSString), releaseDate(NSDate) Relationship: posters<-->> PosterEntity Entity:PosterEntity Attributes: imageLocation(NSURL), defau...

Why does sqlite database randomly revert to previous version in xCode Core Data iPhone project?

Hi All, I'm developing an iPhone Core Data app with a pre-populated sqlite database. In parallel with developing the app in Xcode, we continue to add new data to our sqlite database and so every few days we update the new sqlite database in the project. This is done by adding the sqlite file as a resource in the Xcode project, deleting...