core-data

Core Data calculation result at startup

Thanks for the help. I have a doc based Core Data app consisting of a table with two columns. The column cells are populated with US Currency dollar values. I have two labels at the bottom of each column with Number formatters. Each label displays the sum of it's respective column. I'm doing this with bindings: Bound to the arrayContr...

Why does my boolean value stored in Core Data not show up immediately?

Hello all, Ive been working on a list app where core data is used to persist a checkmark Everything was fine till xcode crashed. No code was changed but now instead of a checkmark showing up immediatly you have to click the row, quit the app, then relaunch it to get anything. This is the code along with an other question of how I got the...

Core data object comparison

Is there an easy/generic way to compare two objects to see if they are the same? By 'same' I mean identical entity name, all attributes and relationships are the same, but the internal object ID is different. Similarly, is there an easy/generic way to find the differences? ...

Optional relationships in Core Data (deleting and checking)

Hi, I have a Core Data model with 2 entities: Game and ScoreTable. A Game has an optional relationship with ScoreTable. I usually check if a game has a ScoreTable by doing: NSManagedObject *scoreTable = [myGame valueForKey: @"scoreTable"]; if (scoreTable == nil) { // wtv } And when I want to delete a ScoreTable from a Game I'll j...

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

Any way to pre populate core data?

Hi all, ive been creating a list app and backing it with core data. I would like to have a default list of say 10 airport items so that the user doesnt have to start from scratch. Is there any way to do this? Any help is appreciated. Thanks in advance. ...

NSSortDescriptor for NSFetchRequestController causes crash when value of sorted attribute is changed

I have an Core Data Entity with a number of attributes, which include amount(float), categoryTotal(float) and category(string) The initial ViewController uses a FethchedResultsController to retrieve the entities, and sorts them based on the category and then the categoryTotal. No problems so far. NSManagedObjectContext *moc = [self ma...

Which iPhone Framework defines NSPersistentDocument?

I've been working on an iPhone app which uses Core Data and I would like to use NSPersistentDocument if I can. I keep seeing discussions about using NSPersistentDocument in iPhone apps but no mention of which iPhone Framework defines NSPersistentDocument? ...

Core-Data: Predicate for To-Many Relationships

I have a CoreData model with 4 entities. Model screenshot -> http://img96.imageshack.us/img96/7857/screenshot20100209at182.png State -StateName Location: -locationName (attribute) -locationDescription -locationActivities (relatinship) -state (relationship) LocationActivities: -location (relationship) ...

Will Core Data create the persistent store file for me?

Please tell me: If I use Core Data in my iPhone app, I have basically two files. The mydatamodel.xcdatamodel file, and then I need an .sqlite file. Apple provides this code snippet: - (NSPersistentStoreCoordinator *)persistentStoreCoordinator { if (persistentStoreCoordinator != nil) { return persistentStoreCoordinator; }...

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

Manipulate table values with PyObjC and Core Data

hi all, I recently started programming with xCode and PyObjC and I'm trying to create a logistics application. I have a table with the store's items and a second table with the expenses. Until now everything worked ok by using just the interface builder to link values to core data information and I didn't have to write any code. Now the ...

Implementing Find-Or-Create During Core Data Flat File Import

I am importing a large plist/XML into Core Data. The structure is simple: let's say there is Person and Company, and a Company can have many Persons. The import goes successfully, but the plist has no established relations, so duplicates of Company are inserted every time multiple people have the same Company. A potential solution lies ...

Core Data iphone debugging pointers

I have a reasonably complex Core Data app for the the iPhone. For the most part, it's working well, but I'm running into a sporadic problem that manifests itself within Core Data. I'm fetching data from a remote service, said service returns data. I parse the data and modify various managed objects. Then I save the managed object con...

How to setup NSPredicate and NSEntityDescription in Coredata to do complicated SQL query

I know how to create NSPredicate to do sql like "SELECT * FROM DRINK". But how about this query: "SELECT I.name, D_I.amount FROM DRINK_INGREDIENT D_I, DRINK, INGREDIENT I WHERE D_I.drinkID=1 AND DRINK.drinkID=1 AND I.ingredientID = D_I.ingredientID;" How do I even set the NSEntityDescription, and NSPredicate for this kind of que...

NSFetchedResultsController based Table View always fails on SECOND insert of entity

I am using an NSFetchedResultsController to manage displaying fetched managed objects in a table view that has one section. The table starts out empty and the user can add new entities to it using the UI. As it stands, the program always works when adding the first entity, and always crashes when adding a second. There is sometimes no...

Type casting for Core Data attribute setting

I am trying to set a Core Data attribute but am getting incompatible type errors. I have a float attribute in a Core Data entity on iPhone 3.0. Core Data auto-generates an interface for a managed data object that provides property access to it: @property (nonatomic, retain) NSNumber * volume; and an implementation for it: @dynamic vo...

String truncated in Core-Data on iPhone

I have an Entity (Article) with an Class defined at xcdatamodel. In this class i defined an String NSString *test; currentArticle.test = string; String is more than 50 characters long. But when i try to fetch the Stored Object with: Article *article = [fetchedResultsController objectAtIndexPath:indexPath]; then article.test is tru...

Cocoa:CoreData - Multiple entities in a ManagedObjectContext

Hi, I have two entities which I modeled as classes and core data model entities too/ The classes look as follows: Class: StateManager #import <Foundation/Foundation.h> #import <CoreData/CoreData.h> #import "StateManager.h" #import "Constants.h" @implementation StateManager @synthesize deviceID, physicalID, applicationName, applic...

How to make an NSFetchRequest which asks for objects that have a specific firstname?

For example, I have a Managed Object Model with an Entity called "Friends", and a friend has a firstName. I want to get all friends where the firstName is equal to "George". How can I do that? ...