Please consider following code:
- (void)viewDidLoad {
[super viewDidLoad];
dispatch_sync(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
for (int i; i < 100 ; i++) {
NSLog(@"%i", i);
}
});
NSLog(@"Main thread code");
}
Why its only output is - 2016-01-26 16:15:28.842 Test[1051:35933] Main thread code
?
I mean, code in global queue is never executed, why? I only want it to execute synchronously. Of course i could easy write dispatch_async, but im just curious why code above not work, does not output anything execept 2016-01-26 16:15:28.842 Test[1051:35933] Main thread code?
dispatch_asyncfor this.%das your string formatting option. Not sure what%iis.