core-data

Sorting NSSets of a core data entity - Objective-c

Hi everyone, I would like to sort the data of a core data NSSet (I know we can do it only with arrays but let me explain...). I have an entity user who has a relationship to-many with the entity recipe. A recipe has the attributes name and id. I would like to get the data such that: NSArray *id = [[user.recipes valueForKey:@"identity"] ...

Displaying a To-Many Relationship in a Table View

I've got an application I've been working on. There are projects and employees, projects can have several employees, employees can work on several projects. Right now I want selecting a project to display which employees are related to it, and allows me to add employees I select from another full-roster list. Somehow, this has proven ...

CoreData could not fulfill a fault when adding new attribute

I am receiving a "CoreData could not fulfill a fault for ..." error message when trying to access a new attribute in a new data model. If I work with new data I'm ok, but when I attempt to read existing data I get the error. Do I need to handle the entity differently myself if the attribute isn't in my original data? I was under the impr...

NSFetchedResultsController Mac OSX Cocoa equivalent

Hi! I am porting some Core Data code from iPhone to Mac OS X. PRoblem is that Core Data Framework on Mac OS X does not have NSFetchedResultsController.h nor NSFetchedResultsControllerDelagete protocol declared. At least I am not able to force Cocoa application to see this class even if I drag Core Framework from iPhone project to link w...

iPhone Coredata saving error

I'm trying to create core data application. Some times when trying to save data, i'm seeing following error: Error: NSInvalidArgumentException, Reason: * -_referenceData64 only defined for abstract class. Define -[NSTemporaryObjectID_default _referenceData64]!, Description: * -_referenceData64 only defined for abstract class. Define...

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

After I apply custom logic, next UI action crashes my app.

I've got an team (eveningRoster) that I'm making a button add employees to. The team is really a relationship to that night's event, but it's represented with an AC. I wanted to make sure an employee did not belong to the team before it adds, so I added a method to MyDocument to check first. It seems to work, the error logs complete, b...

How do I bind an iTunes style source list to an NSTableView using Core Data?

I have an iTunes style interface in my application: Source list (NSOutlineView) on the left that contains different libraries and playlists with an NSTableView on the right side of the interface displaying information for "Presentations". Similar to iTunes, I am showing the same type of information in the table view whether a library or...

Core Data Null Relationship

I have a to-one relationship in my data model with Core Data. I'm trying to set the value of the relationship but Core Data keeps thinking that it's nil. The "creatorUser" relationship is not optional, so when I go to save my managed object context, Core Data gives errors because it thinks the "creatorUser" is nil. Any help would be gr...

Distinct Value Array for View Controller Index Using Core Data

Hi, I'm trying to create an index representing the first letter value of each record in a Core Data store to be used in a table view controller. I'm using a snippet of the code from Apple's documentation. I would simply like to produce an array or dictionary of distinct values as the result. My store already has the character defined wi...

How to populate a core data store programmatically?

Edit: a minimal project that exhibits the crash can be downloaded from crashTest. It was created by choosing the "navigation based with core data" project template in XCode and modifying maybe ten lines. I have ran out of hairs to pull with a crash when a section and two objects are added in one go. The crash happens at the end of the ...

Core Data: Merging multiple Managed Object Contexts and deleting objects

I have an iPhone project where I have a series of Managed Objects in a Managed Object Context within the main application thread. On a separate thread, I import new objects from a webserver into a second Managed Object Context. If the import goes ok without errors, I save the import context. This triggers contextDidSave from which I c...

Google Toolbox For Mac with Core Data on iPhone results in error

I have set up my project for using Google Toolbox for Mac as described on official wiki. And everything is working as expected. For core data usage I have created a 'database' class that uses for final application SQLite storage (this is done based on Xcode template code). For unit tests I have created separate init method for 'databas...

Core Data: NSFetchRequest sorting by count of to-many relationship

Say I have an parent entity, each of which have a number of children. I want to get all the parents sorted by their number of children. Something similar to the following pseudo code: NSEntityDescription * entity = [NSEntityDescription entityForName:@"Parent" inManagedObjectContext:managedObjectContext]; [[NSSortDescriptor alloc] initW...

Core data and saving the context in subViewControllers, ok to release?

When updating the managedObjectContext is it ok practice to do the save setup in view controllers that may be released or should the appDelegate handle the saving of the managedObjectContext so that even if the viewController is released the save finishes? I'm leaning towards the idea of moving the save step into my appDelegate and havi...

Core Data: Detecting the type and casting it

I have set up a Core Data model that includes an entity, Item with a 1->M relationship with the abstract entity Place, so that an item has many places. There are several entities with the parent set to Place. I want to set up several UI elements depending on the descendent place types. I have a loop that looks something like this: for ...

First Letter Section Headers with Core Data

I'm trying to create a list of people sorted in a tableView of sections with the first letter as the title for each section - a la Address Book. I've got it all working, though there is a bit of an issue with the sort order. Here is the way I'm doing it now: NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NS...

NSPredicate to exclude NSManagedObjects that haven't been saved in an NSFetchedResultsController

Building on this question, I've managed to use undo groups and a single managed object context to handle adding a Cocktail that can reference existing Ingredients and/or Brands. Now I'm stuck with a UI nit -- in the fetched results controller (sorted by cocktail.name) you can briefly see an empty row for the to-be-added Cocktail. Marcus...

Faking a dynamic schema in Core Data?

From reading the Apple Docs on Core Data, I've learned that you should not use Core Data when you need a dynamic schema. If I wanted to provide the user the ability to create their own properties, in a core data model would it work if I created some "dummy" attributes like "custom decimal 1", "custom decimal 2", "custom text 1", "custom...

Load CoreData objects' string property into UIPickerView

Hello Currently I have an entity named "Events" in a CoreData app. "Events" has one string property named "eventName". In the -(void)viewDidLoad I am trying to Fetch all the "Events" objects and load their "eventName" by alphabetical order into a UIPickerView. The ultimate end goal is through the use of a textField, buttons and the p...