nssortdescriptor

NSFetchResultsController + sectionNameKeyPath + section order

I have a one to many entity relationship between two entities: EntityP (Parent) <-->> EntityC (Child) Attributes and Relationships: EntityP.title EntityP.dateTimeStamp EntityP.PtoC (relationship) EntityC.title EntityC.dateTimeStamp EntityC.CtoP (relationship) // Can be used to get "one" EntityP record I use fetch results controlle...

Custom sorting using categories and core data - is it supported by the framework?

I'm developing for iPhone iOS 4.0 and I have a list of birthday objects (date + name) stored using Core Data. I want to use the NSFetchedResultsController to retrieve this list sorted by the next birthdate date of each birthday object. For that I need to define my own logic for the sort descriptor. I tried using: [NSSortDescriptor sort...

COMPILED Core Data Managed Object Model: Get maximum info from it and its corresponding database

Hi everybody, I am a novice in Objective-C; and I could not find any solution in my Books or internet. My question: What are the most efficient and fastest ways to use already compiled .mom and SQLite db without having the source codes? Details: I am trying to connect my small app to the database of another application and use (read-in...

Some sorting problems (Core Data beginner)

Hi all. Maybe there is a simple solution to this, but I'm getting headache of this, I'm fairly new with all this Core Data stuff: I have a BankAccount class/entity with an "index" attribute, used for sorting, and a "transactions" to-many relationship to the Transaction class/entity. This Transaction entity has a "date" attribute, that ...

How to set indicator image on column with multiple sort descriptors?

NSDisableScreenUpdates(); [self.productsArrayController setFetchPredicate:predicate]; [self.productsArrayController setSortDescriptors:sortDescriptors]; [self.productsArrayController fetchWithRequest:[self.productsArrayController defaultFetchRequest] merge:YES error:nil]; NSSortDescriptor *lastSortDescriptor = [sortDescriptors lastObj...

Comparing 2 objects using descriptor array

Is there a function that compares two objects using an array of NSSortDescriptor and returns the NSComparisonResult? (Putting them in an array will not identify equality.) ...

How can you use sort descriptors and predicates with core data transformable fields?

I have an application which I wrote which used to work perfectly fine. There is new requirement that all data needs to be encrypted now, so I implemented encryption by making all my core data fields type transformable and writing custom transformers for each data type which encrypts/decrypts each element of data as it is written/read fro...

How should I fix this code?

I'm trying to sort an array of people objects. The class looks like this. Person ------- name phone I have an NSMutableArray filled with these objects. I want to sort this array by the name of each person object. This is the code I tried. NSSortDescriptor *desc = [[NSSortDescriptor alloc] initWithKey: @"name" ascending: YES]; [pers...

Core Data - GROUP BY

I am trying to group results returned by Core Data. I read that you need to use "SortDescriptors" with a selector but I cant seem to get it to work? I am trying to return group'ed "unique" name values? http://developer.apple.com/library/ios/#documentation/cocoa/Conceptual/SortDescriptors/Concepts/Creating.html Thanks James ...

Sort on to-many relationship using a NSFetchedResultsController

I'm trying to use the NSFetchedResultsController in my app, but have a problem to sort my data. I get the following error when trying to sort the result using a relationship that is two levels down from the entity: * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'to-many key not allowed here' M...

Core Data sorting in one to many relationship

I have setup a data model where Student Entity has a name a 1-to-many relationship with Subject. Each Subject that he attends has a number of Class Times. The code below sorts it, based on the Student name, this is straight forward. NSEntityDescription *entity = [NSEntityDescription entityForName:@"Student" inManagedObjectContext:...

NSSortDescriptor is not working while fetching records from Core Data.

I am trying to use NSSortDescriptor in Core Data to fetch my records. Array of modal-objects doesn't get affected by sort descriptor. It gives records in same order.Here is my code: NSManagedObjectContext *moc=[self managedObjectContext]; NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init]; NSEntityDescription *entity = [NSEnti...

Sorting a to-many relationship when calling NSFetchRequest

I have two entities. Client and Project. A Client has many Projects, but a Project can only be assigned to one Client. This has been designed with the datamodel. Client entity has attribute clientName and relationship to-many projects Project entity has attribute projectName and relationship to-one client I want to retrieve all Cli...

Sorting an NSArray using another NSArray as a guide

So, imagine you have a couple of arrays, Colors and Shapes, like this: Colors: { Yellow, Blue, Red } Shapes: { Square, Circle, Diamond } Now, if I want to sort Colors into alphabetical order I can do something like this: NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:nil ascending:YES selector:@selector(loc...

Is it possible to have Core Data sort the "many" part of a To-Many relationship during a fetch request?

I'm using Core Data to cache a decent amount of information, and I have a To-Many relationship set up among my managed objects. Naturally I use an NSFetchRequest to fetch an array of the singular side of that relationship. However, I populate a UITableView using the the "many" side of the relationship, and I'd like it to be sorted alphab...