In my Core Data application I have only one table like this:
What I want is a query which returns all rows group by subject in the ascending order of date,
ie
I am not familiar with Core Data predicates. How can I accomplish this?
In my Core Data application I have only one table like this:
What I want is a query which returns all rows group by subject in the ascending order of date,
ie
I am not familiar with Core Data predicates. How can I accomplish this?
you can write the code like this :-
NSPredicate *predicate = [NSPredicate predicateWithFormat:@"Subject == 'Leave'"];
you will get the list of Subjects with title Leave.Now you can Modify the code as per your requirement.
This will help you to get them in ascending order:-
NSSortDescriptor *sortDescriptor = [[NSSortDescriptor alloc] initWithKey:@"date"
ascending:YES];
NSArray *sortDescriptors = [[NSArray alloc] initWithObjects:sortDescriptor, nil];
[fetchRequest setSortDescriptors:sortDescriptors];
For references:-https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/Predicates/Articles/pSyntax.html