Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Swift 3: Cannot call value of non-function type '(() -> Void)?'

This function worked before the curse of all curses, also known as Swift 3. After migrating to Swift 3, Xcode, my friendly and cuddly IDE, displays this frustrating error against the line SCNTransaction.completionBlock:

Cannot call value of non-function type '(() -> Void)?'

Several other posts deal with similar errors, but none of those solutions apply.

What is wrong with the line???

func test(_ block: SCNNode, animated: Bool) {
    // Do stuff
    SCNTransaction.begin()
    SCNTransaction.animationDuration = animated ? AnimationDur : 0.0
    SCNTransaction.completionBlock {
        block.removeFromParentNode()
    }
    // Animate stuff
    SCNTransaction.commit()
}
like image 575
Crashalot Avatar asked Nov 29 '22 23:11

Crashalot


1 Answers

SCNTransaction.completionBlock is a class property. Perhaps you mean this?

//                             ↓
SCNTransaction.completionBlock = {
    block.removeFromParentNode()
}
like image 113
kennytm Avatar answered Dec 05 '22 13:12

kennytm