Skip to content

Instantly share code, notes, and snippets.

@kinwahlai
Last active December 20, 2015 13:18
Show Gist options
  • Save kinwahlai/6137269 to your computer and use it in GitHub Desktop.
Save kinwahlai/6137269 to your computer and use it in GitHub Desktop.
#import <CouchbaseLite/CouchbaseLite.h>
@interface CBLQueryEnumerator (EnumeratorByBlock)
- (void)enumerateQueryRowsUsingBlock:(void (^)(id key,id value, NSUInteger idx, BOOL *stop))block;
@end
#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