core-data

How to setup a predicate for this query

I have an 3 object hierarchy which has a root as 'Division' that has many 'Group' items and each 'Group' has many 'Employees'. Division [1]------[*] Group Group [1]------[*] Employee I would like to know how to create an NSPredicate to search for all Employees of all Groups of a specific Division, sorted by creation date/time...

Getting started in Core Data for iPhone?

I want to implement Core Data into my iPhone app. So what is the best way to learn Core Data specifically for the iPhone? I have 4ish hours that i can devote to this today, so ideally I would be competent enough to add this (however slightly) into my app. The only way i retain data now is through NSUserDefaults, just so that when the ap...

Should an NSLock instance be "global"?

Should I make a single NSLock instance in the application delegate, to be used by all classes? Or is it advisable to have each class instantiate its own NSLock instance as needed? Would the locking work in the second case, if I, for example, had access to a managed object context that is spread across two view controllers? ...

Core Data, iPhone, setting an attribute on an entity and retrieving it with "one-to-many" relations

Hi I have been through the Apple Developer guides and tutorials and I been through 2 iPhone books brushing on the subject of Core Data. I am used to handling the "value object"/"entity" side of things and then send them of to a web service or the likes. But on the iPhone I get to handle everything myself… cruel world:) The Locations, T...

Is there a way to visualize records stored in an iPhone app via Core Data?

I have an app which, for good reasons, can only be debugged on a device. I'm using Core Data for the first time, and I'd like to be able to easily inspect the records that are stored by the app on the device. I imagine that Core Data is by default backed by SQLite on the iPhone, so this question might be as simple as asking: "What's the...

Group of sections not consistent when using NSFetchedResultsController

I am working with a NSFetchedResultsController whose fetchRequest has a predicate. However, it seems that the query doesn't give me consistent groupings each time I execute it. I've set the 'sectionNameKeyPath' for the NSFetchedResultsController and I get a different number of sections returned based on whether I have been working with ...

Synchronize Core Data with SQL or MySQL Via SQLite

I am trying to build an iPhone application using core data's built in table management. I want synchronize the data with an MSSQL or MySQL database. Core data is compatible with SQLite so I thought it might work as a bridge. Can anyone think of how one might achieve this functionality? ...

Setting up relationships while importing core data?

I have an in memory managed object context called importMoc that I use to import records (e.g. employees). I have parsed a file and set up the employee objects in importMoc with one very important exception. The user confirms they want to process %d employees but I can't quite figure out how or when to set the "parent" relationship of th...

Why this code fails to empty undo stack

- (void)cancel { // [managedObjectContext.undoManager disableUndoRegistration]; [managedObjectContext deleteObject:object]; // I don't want this deletion to be recorded on the undo stack which is empty at this point. // [managedObjectContext.undoManager enableUndoRegistration]; [managedObjectContext.undoManager removeAllAct...

Displaying count of the value of a to-many relationship in an iPhone app

Hi, I need help with a little something. I use Core Data to make this happen: I have a main tableView where categories are stored. When one of the categories are pressed, another tableView is pushed and display that specific categories content. There is a one-to-many relationship between the category and content. I want to displa...

Why is my transformable Core Data attribute not using my custom NSValueTransformer?

I have a Core Data app with a fairly simple data model. I want to be able to store instances of NSImage in the persistent store as PNG Bitmap NSData objects, to save space. To this end, I wrote a simple NSValueTransformer to convert an NSImage to NSData in PNG bitmap format. I am registering the value transformer with this code in my Ap...

How do I delete an entity when removing it from an array controller?

I have an entity (e.g. Employee) in a managed object model that is related to two other entities (e.g. Department and Team). Both relationships are one-to-many (i.e. an Employee must have one Department and one Team, Teams and Departments have many Employees). The two may or may not overlap (e.g. a team might be made up of employees from...

Core Data backed UITableView with indexing

I am trying to implement a Core Data backed UITableView that supports indexing (eg: the characters that appear down the side, and the section headers that go with them). I have no problems at all implementing this without Core Data using: - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; - (NSA...

countForFetchRequest behavior

Hi, I'm newbie in coredata and still learning. I have an application which need to fetch number of records which fulfill given criteria. Assume I have 3 types of Entity, i.e. Entry, Tag and Attachment. Entry has to-many relationship with Tag and Attachment. Tag has to-one relationship with Entry. Attachment has to-one relationship with...

Search on Core data backed UITable issue?

Hi All, Not sure if this is the right place (I am sure someone will let me know if it is not) I have a iPhone application that has a UITableview that is backed by core data. I want to perform a reducing search so that only the items starting with the characters entered into the search bar are shown. This is normally done with the dele...

Storing identical data efficiently in a Core Data data model

I have a data model that contains several entities, each with several different attributes that store image data. These will all be small images and I need to store them in the persistent store rather than as external files. While I can just store the image data in a Binary or Transformable attribute, it's quite likely that the user wil...

Sort NSArray by NSDate, today

Hi, I have loaded item from core data in an NSMutableArray. Each item, when created, is given a due date, that the user choices. How do I sort, so only the item that is due today is displayed? Here is what I got so far: NSPredicate *predicate = [NSPredicate predicateWithFormat: @"dueDate == %@", [NSDate date]]; [allObjectsArray ...

Is there a good Core Data browsing tool out there?

One of the things I miss from moving from SQLite to Core Data is the ability to query directly against my database to analyze data. Is anyone out there aware of a tool that allows for the browsing of a Core Data store in a similar fashion? ...

iPhone dev: how do you print results from a Core Data fetchRequest?

I've added the following to the AppDelegate in the Core Data Recipes example, but I don't get any printed result in the Console...any ideas? #pragma mark - #pragma mark TESTING RETRIEVAL OF RECIPE NAMES - (NSArray *)allRecipes{ NSFetchRequest *request = [[[NSFetchRequest alloc] init] autorelease]; NSEntityDescription *entity = ...

CoreData countForFetchRequest says 'entity not found'

I'm experiencing a strange problem when trying to count the entities in a managed object context. - (NSUInteger)countEntity:(NSString *)entityName inContext:(NSManagedObjectContext *)context{ NSFetchRequest *request = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEntityDescription entityForNam...