Last active
December 28, 2015 11:39
-
-
Save bagelturf/7494689 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
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