Skip to content

Instantly share code, notes, and snippets.

@dermotos
Created October 1, 2013 04:29
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 dermotos/6773870 to your computer and use it in GitHub Desktop.
Save dermotos/6773870 to your computer and use it in GitHub Desktop.
-(void)doCodeSnippetWithCompletion:(void(^)())block{
//dispatching to background queue
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
NSString *code = @"Code", *test = @"Test";
BOOL iterationPrinted = NO;
for (int x = 1; x<=100; x++) {
iterationPrinted = NO;
if(x % 3 == 0 && x % 5 == 0)
NSLog(@"%@%@",code,test);
else if(x % 5 == 0)
NSLog(@"%@",test);
else if(x % 3 == 0)
NSLog(@"%@",code);
else
NSLog(@"%d",x);
}
if(block) //completion callback (optional)
block();
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment