core-data

When should I use a prefix on Objective C classes?

According to Apple, two to three letter prefixes should be used when naming classes, protocols, functions, constants, and typedef structures. Does this include classes which are not intended to be part of a framework, simply used internally in an application? I realize this is relying on other developers that develop frameworks yo...

Filtering entries from a Core Data entity that appear in an NSPopUpButton list

I'm familiar with how to feed data from one Core Data entity into an NSPopUpButton item so that it can be selected for another. Bindings like so: For the values themselves: -> ValueSelection.Content Bind To: Value Source Entity Controller Key: arrangedObjects Model Key: N/A For the values displayed in the NSPopUpButton: ...

Allowing the user to submit images within a Cocoa application

How do you set up an object in interface builder that will allow the user to submit an image (like when editing a vCard in Address Book) and save it to the corresponding entry in the database being managed by Core Data? Solution Use an NSImageView object. On the first panel of the inspector for the object, you'll see a checkbox marked...

How to unit test my models now that I am using Core Data?

I have been developing an iphone application using a domain model, and have put off the persistence aspect of the app until now. Core Data looks like a really good solution since I already have a well defined model but I am running into a snag with my existing unit tests. Here is simple example of what I have now: - (void)test_full_na...

Use Core Data For Storage for an existing Iphone project?

Hello, According to the Apple Core Data Tutorial, in order to use Core Data you have to: In the Options section, select the switch to use Core Data for storage. How do it for an existing project? Do you have to import some files? Can that setting be activated later on? Thanks ...

Tinkering under the hood with Bindings in Xcode

Let's take two Core Data entities, set up as follows: Entity A: Car Attributes: year model Relationships: manufacturer (<<-> Manufacturer) Entity B: Manufacturer Attributes: name country Relationships: cars (<->> Car) Now, what I want to do is bind the display to an NSTableView where we have the model of th...

Core Data + Core Animation/CALayer together??

I am making an Cocoa app with custom interfaces. So far I have implemented one version of the app using CALayer doing the rendering, which has been great given the hierarchical structure of CALayers, and its [hitTest:] function for handling mouse events. In this early version, the model of the app are my custom classes. However, as the ...

Getting and Setting values from Core Data elements in Objective-C?

I've got a simple application with two entities: Person: Attributes: name Relationships: nativeLanguage: (<<-> Language.natives) nonNativeLanguage: (<<-> Language.nonNatives) Language: Attributes: name Relationships: natives: (<->> Person.nativeLanguage) nonNatives: (<->> Person.nonNativeLanguage) On the ed...

KVC select by criteria

I have a array of objects that selected from core data. I need select from this set subset of object that correspond to condition. How to do it? ...

Core Data: entity properties getting mixed

I have an NSWindow which I use to create new records. After pressing the Add button, a certain method is called in which I do the following: - (IBAction)addActionAddSheet:sender { NSManagedObjectContext *moc = [self managedObjectContext]; NSManagedObject *newObject = [NSEntityDescription insertNewObjectForEntityForName:@"Recipe" inM...

Relationships vs. Attributes in Core Data

Overall I'm loving Core Data so far, but there is one quirk in the system that I keep coming back to, and that's problems created when I decide to use relationships instead of attributes. Using cars for an example, let's say I have a Car entity and a Manufacturer entity. Ideally, I can just put a relationship between them, many cars to...

iphone sqlite NSDate bug

Hi, i use core data in my iphone app, but in some case i use sqlite to access to data and ia have a problem with NSDate. NSDate *now = [NSDate date]; NSCalendar *calender = [NSCalendar currentCalendar];; NSDateComponents *comp = [calender components:NSYearCalendarUnit fromDate:now]; [comp setDay:1]; [comp setMonth:1]...

NSArrayController initialization

I am having trouble getting an core-data backed NSArrayController to work properly in my code. Below is my code: pageArrayController = [[NSArrayController alloc] initWithContent:nil]; [pageArrayController setManagedObjectContext:[self managedObjectContext]]; [pageArrayController setEntityName:@"Page"]; [pageArrayController s...

CoreData Book Recommendation

I'm looking for a comprehensive book on CoreData. I'm rather frustrated with the many Apple documents that do not seem to be assembled into a single reference work or even at a single place, it is too easy to miss (or find) a key document. I have the Zarra book "Core Data"but it is rather lightweight. Here are the docs I have found, I...

setPropertiesToFetch doesn't seem to have any affect

I'm trying to use setPropertiesToFetch in my fetch request to limit the data that is retrieved from my store, but it seems to have no affect. When I use it and display the object returned into the console, I can see all my properties are there. The same data is displayed whether I set the properties or not. All the relationships display ...

mergeChangesFromContextDidSaveNotification taking almost a minute

I have a managed object context in a separate thread that is creating a few hundred managed objects, and when it saves, the did save notification is passed to the main thread and my other context (on the main thread) is updated: In Thread [ApplicationDelegate performSelectorOnMainThread:@selector(managedObjectContextDidSave:) ...

iPhone - Core Data crash on migration

I have problems, when i install app from Xcode all works but if I build app and install it from iTunes I have an error with the database at launch. This happens only than i have changes in the core data model and need to migrate to a new version. At first launch at crashes with message: Thread 0: 0 libSystem.B.dylib 0x0...

Core Data not saving a relationship that has been deleted

I have a "to->many" relationship in Core Data with no inverse relationship and the delete rule set to both "Nullify" and "No action" (by that I mean I've tried both with no avail) Basically I have a MergedStation whose property subStations points to many Station objects: MergedStation.subStation -->> Station When I call [mergedStation ...

OCMock with Core Data dynamic properties problem

I'm using OCMock to mock some Core Data objects. Previously, I had the properties implemented with Objective-C 1.0 style explicit accessors: // -- Old Core Data object header @interface MyItem : NSManagedObject {} - (NSString *) PDFName; - (void) setPDFName:(NSString *)pdfName; @end // -- implementation provides generated implementatio...

Full Text Searching in Apple's Core Data Framework

I would like to implement a full text search in an iPhone application. I have data stored in an sqlite database that I access via the Core Data framework. Just using predicates and ORing a bunch of "contains[cd]" phrases for every search word and column does not work well at all. What have you done that seems to work well? ...