When i try to use the MR_findAllSortedBy
function with multiple keys, i get a keypath not found error. However, when i use this function with only one of the two keypaths it works. I can't figure why it doesn't work.
My code
-(void)performActionOnEachTrajetWithBlock:(void (^) (Trajet *trajet, NSArray *previousTrajets))actionBlock{
NSMutableArray *previousTrajets = [NSMutableArray arrayWithArray:@[]];
for (Trajet *trajet in [Trajet MR_findAllSortedBy:@"isActive, date" ascending:YES]){
actionBlock(trajet, [NSArray arrayWithArray:previousTrajets]);
[previousTrajets addObject:trajet];
}
return;
}
The error
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'keypath date not found in entity <NSSQLEntity Trajet id=2>'
Thank you for helping me.
There must be no space in the first argument of
[Trajet MR_findAllSortedBy:@"isActive, date" ascending:YES]
// remove this space ------------^
otherwise MagicalRecord will create a sort descriptor for the key " date" instead of "date".
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