How to use threading in swift?
dispatchOnMainThread:^{
NSLog(@"Block Executed On %s", dispatch_queue_get_label(dispatch_get_current_queue()));
}];
cocoa-touchdispatch-queueiosmultithreadingswift
How to use threading in swift?
dispatchOnMainThread:^{
NSLog(@"Block Executed On %s", dispatch_queue_get_label(dispatch_get_current_queue()));
}];
Best Answer
Swift 3.0+
A lot has been modernized in Swift 3.0. Running something on a background queue looks like this:
Swift 1.2 through 2.3
Pre Swift 1.2 – Known issue
As of Swift 1.1 Apple didn't support the above syntax without some modifications. Passing
QOS_CLASS_USER_INITIATED
didn't actually work, instead useInt(QOS_CLASS_USER_INITIATED.value)
.For more information see Apples documentation