{ if (![obj isKindOfClass:Bookmark.class]) { return nil; } } NSPredicate *predicate = [NSPredicate predicateWithBlock:^(Bookmark *b, NSDictionary *bindings) { return b.isHotentry; }]; NSArray *hotentries = [bookmarks filteredArrayUsingPredicate:predicate]; NSSortDescriptor *descriptor = [NSSortDescriptor sortDescriptorWithKey:@"bookmarked" ascending:NO]; NSArray *sortedHotentries = [hotentries sortedArrayUsingDescriptors:@[descriptor]]; return sortedHotentries.firstObject; }