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
}