Skip to content

Instantly share code, notes, and snippets.

@bagelturf
Last active December 28, 2015 11:39
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bagelturf/7494689 to your computer and use it in GitHub Desktop.
Save bagelturf/7494689 to your computer and use it in GitHub Desktop.
non-ARC recursive block
void __block (^batchReaderRecursive)(NSUInteger position, NSUInteger count); // Used for the recursive reference
void (^batchReader)(NSUInteger position, NSUInteger count); // Used to reference the block
batchReaderRecursive = batchReader = [^(NSUInteger position, NSUInteger count) {
dispatch_async(background queue, ^{
// Do work, update position abd count
dispatch_async(main queue, ^{
if(work remains) {
batchReaderRecursive(nextPosition, nextCount);
else
[batchReaderRecursive release];
});
});
} copy];
batchReader(0,itemCount);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment