Objective-C delay a method in iOS 6 dispatch_get_current_queue deprecated
ios, objective-c
Solution
I think you should use `dispatch_get_global_queue()` instead. It should do about the same i think. If you are only interested in delaying the method and not running in another que you could just use `dispatch_get_main_queue()`. Just remember that you can't update user interface if you are not in the main que.
Problem
I am using `dispatch_after()` and `dispatch_get_current_queue()` to delay a method at the moment. For example, delay for 1 second: ``` dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_current_queue(), ^{ [self someMethod]; }); ``` As `dispatch_get_current_queue()` is deprecated from iOS 6, is there any other equivalent way to do this without creating another separated method for `performSelector:withObject:afterDelay:`? A similar question here but still using the deprecated way. Thanks! EDIT: From Peter Segerblom's answer: ``` // Without updating UI dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ NSLog(@"Hello World"); }); // updating UI dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{ UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)]; [imageView setBackgroundColor:[UIColor redColor]]; [self.view addSubview:imageView]; }); ``` Cheers!