Last active
August 29, 2015 14:08
-
-
Save fjolnir/49dd5e59052afb7e4d99 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <DatabaseKit/DatabaseKit.h> | |
#import "FLazyArray+CoineyKitAdditions.h" | |
@implementation FLazyArray (CoineyKitAdditions) | |
+ (instancetype)lazyArrayWithQuery:(DBSelectQuery * const)aQuery | |
{ | |
return !aQuery ? nil : [self lazyArrayWithCount:[aQuery count] | |
resolver:^(NSIndexSet *aIndexes, __strong id *aoObjects) | |
{ | |
__block __strong DBModel **objects = aoObjects; | |
[aIndexes enumerateRangesUsingBlock:^(NSRange range, BOOL *stop) { | |
DBSelectQuery *objectsInRange = [[aQuery offset:range.location] limit:range.length]; | |
for(DBModel *object in [objectsInRange execute]) { | |
*objects++ = object; | |
} | |
}]; | |
}]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment