We can declare block as below in Objective-C.
typedef void (^CompletionBlock) (NSString* completionReason);
I'm trying to do this in swift, it give error.
func completionFunction(NSString* completionReason){ }
typealias CompletionBlock = completionFunction
Error : Use of undeclared 'completionFunction'
Definition :
var completion: CompletionBlock = { }
How to do this?
Update:
According to @jtbandes's answer, I can create closure with multiple arguments as like
typealias CompletionBlock = ( completionName : NSString, flag : Int) -> ()
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…