Last active
December 20, 2015 13:18
-
-
Save kinwahlai/6137269 to your computer and use it in GitHub Desktop.
This file contains 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 <CouchbaseLite/CouchbaseLite.h> | |
@interface CBLQueryEnumerator (EnumeratorByBlock) | |
- (void)enumerateQueryRowsUsingBlock:(void (^)(id key,id value, NSUInteger idx, BOOL *stop))block; | |
@end |
This file contains 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 "CBLQueryEnumerator+EnumeratorByBlock.h" | |
@implementation CBLQueryEnumerator (EnumeratorByBlock) | |
- (void)enumerateQueryRowsUsingBlock:(void (^)(id key,id value, NSUInteger idx, BOOL *stop))block | |
{ | |
NSUInteger index = 0; | |
BOOL stop = NO; | |
while ((row = self.nextObject)) { | |
if (stop) { | |
break; | |
} | |
block(row.key,row.value,index,&stop); | |
index ++; | |
} | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment