Arun Kumar Arun Kumar - 1 year ago 188
Swift Question

__block in Swift

__block keyword on a variable in objective c used to assure that this variable will be treated specially in block but what is the equivalent to this keyword in swift?

I have done some google research but everything confuses me so far.

Following is my code,

var myArr = NSMutableArray()
completionBlock(myArray,nil)


I have tried

__block var myArr = NSMutableArray()

Answer Source

There is no need for __block in Swift. A captured variable is automatically settable from within the closure.