LoginSignup
1
1

More than 5 years have passed since last update.

ObjC to Swift : [NSOperationQueue addOperationWithBlock:]

Last updated at Posted at 2015-05-03

Objective-C (main queue)

[[NSOperationQueue mainQueue] addOperationWithBlock:
^{
    //  do some UI stuff
}];

Objective-C (background queue)

NSOperationQueue * backgroundQueue = [[NSOperationQueue alloc] init];

[backgroundQueue addOperationWithBlock:
^{
    //  do some heavy stuff in background
}];



Swift (main queue)

NSOperationQueue.mainQueue().addOperationWithBlock
{() -> Void in

    //  do some UI stuff
}

Swift (background queue)

let backgroundQueue = NSOperationQueue()

backgroundQueue.addOperationWithBlock
{() -> Void in

    //  do some heavy stuff in background
}
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1