core-data

Core Data Deletion rules and many-to-many relationships

Say you have departments and employees and each department has several employees, but each employee can also be part of several departments. So there is a many-to-many relationship between employees and departments. When deleting a department I would like to delete all employees that are only part of that department and nullify the rela...

Method/IBAction stuck in infinite loop. Still no success.

Now this may sound like my earlier problem/question but I've changed and tried a few things that were answered in my other questions to try to make it work, but I've still got the same problem. I am observing a core data property from within a NSManagedObject sub-class and the method that gets called when the property changes calls anot...

Design pattern for Core Data iPhone App

Hi Im building an app that will use a Core Data model. I pretty new at Objective C and my usual design patterns does not really apply on Core Data and Objective C, at least I can't seem to find examples that confirms they will. I have been through the Apple Developer examples and different sources on the intertubes. It seems that to l...

Core Data, NSTableColumn bindings and custom NSCell

I'm trying to display an array of NSManagedObjects in a NSTableView using a custom NSCell that is able to draw the managed object properly. For that matter, the single column of my NSTableView is binded to the arrangedObjects of a NSArrayController. I'm not using any key paths on the object. I was under the impression that my NSCell s...

setPropertiesToFetch doesn't work as expected

I want a list of unique contacts that I've stored with core data. NSEntityDescription *entityDescription = [NSEntityDescription entityForName:@"Post" inManagedObjectContext:[self managedObjectContext]]; NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; [request setEntity:entityDescription]; ...

How do I create many temporary objects and then save only one using Core Data?

I am working on an application that will perform a search against an online service and generate many Result objects. A Result object is an NSManagedObject, initialized as required by associating it with an NSManagedObjectContext. Users should be able to select a "Result" and save it as a "Favorite". In the application this is as simple...

Implement Itunes like "All" filter in master detail interface

In Itunes, there is an "All" filter in the music browser. The user, e.g., can select "All (350 Artists)" to see music across all artists. I have a Core Data backed Master Detail interface where I have a list of groups as master and a list of items in the group as detail, both NSTableViews. I have connected the 2 views together through...

Core Data Classes vs Model

I've recently started down the road of programming in Objective-C, and I'm now looking into Core Data. However, I am confused about exactly what defines the model itself in Core Data. Here's what I mean: Say I create an entity with some set of attributes using the graphical model builder. I then have Xcode generate code for the corre...

Best way to implement Enums with Core Data

What is the best way to bind Core Data entities to enum values so that I am able to assign a type property to the entity? In other words, I have an entity called Item with an itemType property that I want to be bound to an enum, what is the best way of going about this. ...

CoreData: Find minimum of calculated property

Say I have a CoreData entity "Point" with two properties x and y (both NSNumber). How would a NSPredicate need to look like to let me find the closest Point to say a,b? for distance = sqrt((x-a)(x-a)+(y-b)(y-b)) While I could define a transient property that calculates a distance to a predefined point I can't see how I could programma...

Stopping a loop.

As explained in my earlier question … This code … - (void)syncKVO:(id)sender { NSManagedObjectContext *moc = [self managedObjectContext]; [syncButton setTitle:@"Syncing..."]; NSString *dateText = (@"Last Sync : %d", [NSDate date]); [syncDate setStringValue:dateText]; NSEntityDescription *entityDescription = [NSEntit...

how to write an If statement, to compare core data attribute value?

i'm an objective-c newcomer. im trying to compare a core data entity attribute value and having trouble with the syntax. i just want to know the best way way to write the if statement to compare values. in this example, the someAttribute attribute is a boolean, and its default is NO. NSString *myValue = [NSString stringWithFormat:@"%...

Getting the Minimum Value of an Attribute in a NSSet Made from a One-to-Many Relationship in Core Data

I have several objects set up in Core Data, one of which is "Deck" and one of which is "Card". "Cards" have several numbered relationships, including "id". "Deck" has a one-to-many relationship with cards. What's the best way to find the Card in a Deck that has the minimum value to some numbered attribute, such as id? Clearly I can get...

Odd behaviour of an NSArrayController

I have a Core Data project with an NSTableView bound to an NSArrayController. I have two buttons, one adding an object to the table and one removing the object from the table. The Add method uses a custom method which directly creates a new Core Data object. The remove method uses the standard Remove method of an NSArrayController. My ...

Managed Object Context in Tab Bar View

Ok. this one's a challenge. I have a tableview within a navigation controller. I push it from the root, where I have an add action that allows me to add a new record. That works fine. Now what I've tried to do is add this tableview to a tab bar view (without a tab bar controller cuz that won't work) but within the same navigation cont...

Using NSMigrationManager to append data to Core Data Persistent Store

I would like to append the contents from one sqlite file (that has been created using Core Data with a Model A) to another sqlite store that is used by my application (which uses the same Model A). The idea is to quickly import large amounts of data. The problem I am facing is that the code below only works once. When I try to run the ...

NSDictionaryResultType expression not taking into account newly inserted objects

Hi there, I want the maximum value of a field in core data so I have set up the following request: // Create fetch NSFetchRequest *fetch = [[NSFetchRequest alloc] init]; [fetch setEntity:[NSEntityDescription entityForName:@"MyEntity" inManagedObjectContext:context]]; [fetch setResultType:NSDictionaryResultType]; // Expression for Max ...

Core-Data iPhone: could not locate an NSManagedObjectModel

Hi, I am using Apple's CoreDataBooks sample project as a learning aid for core data. I modified the app so that when the app loads I show a menu page first - not the Books tableview (RootViewController). I have done the following: I created a menu page in interface builder (just a view with a button on it) The CoreDataBooksAppDeleg...

Apparently random crashes when migrating a Core Data store

I'm attempting to migrate a Core Data SQLite store in my Mac OS X Leopard app. The migration itself is simple, there's just a couple of changes between the model versions, and there's one custom NSEntityMigrationPolicy that does a little bit of string manipulation. 99% of the time, this works perfectly. However, occasionally it crashes ...

Is Core Data useful for readonly data too?

Hi, I'm creating an iPhone App and am wondering whether Core Data is better for readonly data than a SQLite database. It feels like the SQLite DB is the better choice, is that right? Can I even pre-fill the Core Data storage? Basically, I need like 3 tables with a bunch (up to 3000) of entities each. I then want to list the data in Tabl...