modusCell
modusCell

Reputation: 13429

How NSAnimationContext completionHandler work with Swift Language

i couldn't port this to swift, rest of NSAnimationContext straight forward.

[[NSAnimationContext currentContext] setCompletionHandler:^(void) {
    //doSomething here...
}];

in docs it says var completionHandler: (() -> Void)! it did not mean anything to me. Thank you.

Upvotes: 0

Views: 788

Answers (1)

rickster
rickster

Reputation: 126127

() -> Void is the signature for a Swift closure that takes no parameters and returns nothing. Use it much like you would an ObjC block:

NSAnimationContext.currentContext().completionHandler = {
    // do something here
}

Note that since it's declared as a property, you should set it like one -- ObjC getter/setter pairs don't translate to Swift.

Upvotes: 3

Related Questions