core-data

Making a table's display dependent on the selection in another table in Interface Builder

I've got a window set up with two NSTableViews. In Core Data I have two entities set up, one of them containing members of the other, larger grouping (e.g. cars and manufacturers). I've got entry pages set up for each entity and they play nicely there (no faulting when trying to select from a many-to-one in a drop menu). What I'm tryi...

Calculating the max value for a core data attribute - NSCFNumber error

Hi, I need to find out the maximum value of an attribute of a core data entity. I'm still firmly in the Cocoa learning curve, and this is a simple test app that I'm using to learn. The app imports fortunes from a text file and displays a table on the screen. The imports are done in a separate, background thread. I found this code onl...

Suggestions on how to organize Core Data visual layout?

Core Data is pretty amazing, and I've really enjoyed using the visual layout Xcode provides for it to organize things and get a quick sample of what data I've placed where. At times I've started to wonder if I'm making the best use of it, however, as after a while there tends to be such a mass of arrows that it becomes difficult to tell...

How can I override a getter on a propery when using Core Data?

I want to be able to override the getter on a string property on one of my core data models and inside the getter I need to find out what the value is for that property. @interface LabTest : NSManagedObject { } @property (nonatomic, retain) NSString *status; @end @implementation LabTest @dynamic status; - (NSString *)status { NSS...

Modelling entity types using Core Data

I'm working on my first app using Core Data and I need to assign a type (with an associated name attribute) to a couple of entities. Below is my object model so far. The room and item types will be updated from time to time over the network. Is this the best way to implement this using Core Data? Thanks :) Edit: To try to explain be...

CoreData Fetch Request with Most recent Predicate

I have an Entity 'Event' which contains a NSDate 'AccidentDate'. I am trying to do a fetch request to grab only the most recent 'AccidentDate' but I am not sure how to set up the predicate to grab only the last 'AccidentDate' Below is my code so far... NSFetchRequest *fetchRequest1 = [[NSFetchRequest alloc] init]; NSEntityDescription...

Deleting a selected NSTableView row from Core Data?

How would I delete selected NSTableView row and it's corresponding Core Data entry? ...

How to debug Core Data crash on fetch request

Hi guys, the second time I execute [[MOC executeFetchRequest:request error:&error] lastObject]; after having said NSFetchRequest *request = [[NSFetchRequest alloc] init]; [request setEntity:[NSEntityDescription entityForName:@"Login" inManagedObjectContext:MOC]]; NSError *error = nil; it crashes with a EXC_BAD_ACCESS. Included is...

Cannot find NSExpression while compiling for OSX 10.6

I am building a very simply Core Data + Core Animation application. While compiling for OSX 10.6, 64 bits, Xcode keeps throwing the error: /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/CoreData.framework/Headers/NSFetchRequestExpression.h:16:0 /Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks/CoreData.framework/Head...

Auto-persist removing objects from NSArrayController with CoreData

Hi! I have a NSTableView with one column bound to NSArrayController representing a collection of entities from a NSManagedObjectContext. I also have a "remove" button that is connected to NSArrayController's remove action, and it all works fine - table is showing data, when I click 'remove', the entity gets removed from the table etc. ...

NSOutlineView with Bindings driven by Core Data

I've got an NSOutlineView acting as a source list for my application, and my data model is done with Core Data. I'd like to use bindings (if possible) to glue these things together as follows: I have three main entities in my model, for sake of example let's call them "Stores", "Cars" and "People". My goal is to have the outline view h...

Adding custom methods to core data classes

What is the best way to add custom methods to my core data generated classes? For example, say I have a "Person" entity with properties "firstname" and "lastname". I wish to add a "fullname" method, which returns a concatenation of the firstname and lastname properties. I could add the method to the generated .h and .m files, but this...

CoreData Sqllite protection

Hi Guys, I like to use CoreData and their entity model into my projects. I need to know that how to store sqllite database into Iphone securely. As everybody knows when the Iphone broken with jailbreak it have file system navigatable, that mean for me, someone or somebody easly open or copy to another envorinment my sqllite db. How do ...

Setting Core Data property value with float type

In a test iPhone app I am developing, I am trying to set the value of a float field in my Core Data model. The compiler is giving me an incompatible type error even though both the data type specified in my method is a float and the data type in model is a float. This is the first project where I am using Core Data instead of SQLite 3....

user credential persistence in iPhone

Hi Guys, Since i'm new to iPhone programming, I want to do something like that: In the main screen of my app, i ask for username and password and authorize user using these info calling .net web service. In this main screen, there is a switch controller "Remember me" so that app will remember the user next time he run the app. My questio...

setPropertiesToFetch method appears to always make request return faulted objects

Whenever I use setPropertiesToFetch on an NSFetchRequest, the objects that are returned appear to all be faulted. They return YES to isFaulted and when displaying them in the console they appear like this: < MyEntity: 0x5884850> (entity: MyEntity; id: 0x5886180 <x-coredata://4D96A1CB-187C-4D92-A50C-D639F7E69114/MyEntity/p197> ; data: <f...

NSPredicate: filtering objects by day of NSDate property

I have a Core Data model with an NSDate property. I want to filter the database by day. I assume the solution will involve an NSPredicate, but I'm not sure how to put it all together. I know how to compare the day of two NSDates using NSDateComponents and NSCalendar, but how do I filter it with an NSPredicate? Perhaps I need to create ...

CoreData & TimeMachine

Hi, I'm developing a CoreData non-document-based app. The SQLite store size is regularly of order ~60MB, and it's cumbersome that Time Machine backs up the entire database once per hour. Is there a way to make Time Machine back up only the changes? I'm thinking of abusing the CoreData external records API for spotlight and let the mach...

How to fetch only first entity from Core data?

Hi, everyone. It may looks like a newbie question, but I really am. I try to fetch only first object from Core data. But I try to figure out how could I done this? For example, it may have 100 object in Core data for specific entity. I just need the first one. Could you give me your advice? ...

It's possible to get a attribute from NSEntityDescription using a NSString?

Hello There! Im getting the value of an attribute using NSEntityDescription.attributeName, like this: NSEntityDescription *edCurrentRecord = [maListRecords objectAtIndex:indexPath.row]; UILabel *lblCell = [[UILabel alloc] initWithFrame:CGRectMake(5.0, 10.0, 280, 20.0)]; [lblCell setText:edCurrentRecord.name]; There is another way to ...