When working with Swift - Extensions
As you know, we can create variables for function. i want to create a variable which can hold reference to a function which has parameters.
i have managed to create variable for a function which didn't have any parameters defined for
My code is as follows :-
extension UIAlertController {
var cancelBlock : ()->Void { return {} }
var nameBlock : (nameArg:String?)->Void { }
}
I am getting the following error with "nameBlock"
Computed property must have accessors specified
How should i specify return value ?
use
var nameBlock : (nameArg:String?)->Void? { return nil }