In fetchedResultsController
while setting the NSSortDescriptor
iam getting this error unsupported NSSortDescriptor (comparator blocks are not supported).
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSEntityDescription *entity = [NSEntityDescription
entityForName:@"Alarm" inManagedObjectContext: managedObjectContext];
[fetchRequest setEntity:entity];
//Below code is not working and causing error. sorting use the hours&seconds part of the time attribute
NSSortDescriptor *sort = [[NSSortDescriptor alloc]
initWithKey:@"time" ascending:YES comparator:^NSComparisonResult(id obj1, id obj2) {
NSCalendar *calendar = [NSCalendar currentCalendar];
NSDateComponents *components1 = [calendar components:(NSHourCalendarUnit|NSMinuteCalendarUnit) fromDate:obj1];
NSDateComponents *components2 = [calendar components:(NSHourCalendarUnit|NSMinuteCalendarUnit) fromDate:obj2];
NSDate *date1 = [calendar dateFromComponents:components1];
NSDate *date2 = [calendar dateFromComponents:components2];
return [date1 compare:date2];
}];