Say I have two Entities:

Each Message belongs to a single MessageThread. How do I get all the message threads and the corresponding last message on that thread? Normally, in SQL, I'd do it as:
select __ from message group by thread having timeStamp=max(timeStamp)
For one, I don't think Core Data allows the @max in its predicates. Any ideas?
This might be a bit old, but I had a similar problem recently. Here is my solution to the problem:
NSFetchRequest *request = [[NSFetchRequest alloc] initWithEntityName:@"Message"];
request.predicate = [NSPredicate predicateWithFormat:@"timeStamp = [email protected]"];
request.sortDescriptors = @[[NSSortDescriptor sortDescriptorWithKey:@"timeStamp" ascending:NO]];
I hope it helps...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With