Question

I am using Magical Record .. I am using NSFetchRequest like:

NSPredicate *predicate = [NSPredicate predicateWithFormat:@"(due_at < %@) AND complete == 0",startDate];
        NSArray *taskArray = [Task MR_findAllSortedBy:@"due_at" ascending:NO withPredicate:predicate];

i have logged Console and it is:

<NSFetchRequest: 0x16b239b0> (entity: Task; predicate: (due_at < CAST(415186806.000000, "NSDate") AND complete == 0); sortDescriptors: ((
    "(due_at, descending, caseInsensitiveCompare:)"
)); batch size: 20; type: NSManagedObjectResultType; )

It causes me an error of:

[__NSDate caseInsensitiveCompare:]: unrecognized selector sent to instance

How can i solve this issue..

Was it helpful?

Solution

This should help you work around this problem:

NSFetchRequest *request = [Task MR_requestAll];
NSSortDescriptor *sortByDueAtDate = [NSSortDescriptor sortDescriptorWithKey:@"due_at" ascending:NO selector:@selector(compare:)];
[request setSortDescriptors:@[sortByDueAtDate]];

NSArray *results = [Task MR_executeFetchRequest:request];
//continue on with results
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top