38

I am developing a chat application using xmppframework in iOS 5; it works perfectly.

But I updated my Xcode to 4.5.1, iOS 5 to iOS 6 and my Mac OS to 10.7.5, and the project did not work due to deprecation issues. I replaced all methods with new methods in iOS 6 except this one:

dispatch_get_current_queue()  

How can I replace this method in iOS 6?

pkamb
  • 33,281
  • 23
  • 160
  • 191
venkat
  • 762
  • 2
  • 8
  • 20

2 Answers2

4

It depends what you need to achieve with this call.
Apple states that it should be used for debugging anyway.

Perhaps the queue does not matter (as you just need a background queue) so get a global queue with specific priority (dispatch_get_global_queue(dispatch_queue_priority_t priority, unsigned long flags);)

OR,

If you do need to execute some pieces of code in the same queue , create a queue, retain it and dispatch all your tasks there.

Nir Golan
  • 1,336
  • 10
  • 24
2

How about using NSOperationQueue?

-(void) doSomeThing:(void (^)(BOOL success)) completionHandler
{
    NSOperationQueue* callbackQueue = [NSOperationQueue currentQueue];
    if(!callbackQueue) {
        callbackQueue = [NSOperationQueue mainQueue];
    }
    dispatch_async(...,^{
         // do heavyweight stuff here
         // then call completionHandler
         if(completionHandler) {
             [callbackQueue addOperationWithBlock:^{
                 completionHandler(...);
             }];
         }
    });
adib
  • 8,285
  • 6
  • 52
  • 91
  • I'm not sure this is the way to go because now you've just add the last part of your operation to the end of your queue. What if your queue has one max concurrent operation and you have 20 operations in your queue? – horseshoe7 Mar 26 '14 at 18:43