Nil cannot be assigned to type ()->()?

后端 未结 3 1858
花落未央
花落未央 2021-01-14 05:10

So this is a function from a class that lets you have a double tap and a single tap gesture. It\'s working fine in Swift 2.3, but after converting to Swift 3 it\'s throwing

3条回答
  •  天命终不由人
    2021-01-14 05:43

    Here is the way how i could overcome this. Here clang is not aware about its type. I gave a typealias and optional declaration,

    typealias appDelegateBlock = ()->()
    

    In your class, just declare it as optional,

    var block: appDelegateBlock?
    block = task
    

提交回复
热议问题