-3

I am using a custom UISwitch Control called DVSwitch which is written in Objective-C for a Swift/ Xcode6 project. I need to call its -setPressedHandler: Method and having a hard time converting it to Swift. Can anyone please show me how to write the code block below in Swift.

[switcher setPressedHandler: ^(NSUInteger index) {
    NSLog(@"Did switch to index: %lu", (unsigned long)index);
}];
Novarg
  • 7,390
  • 3
  • 38
  • 74
  • possible duplicate of [Syntax of Block in Swift](http://stackoverflow.com/questions/24038713/syntax-of-block-in-swift) – Larme Jan 13 '15 at 14:19

1 Answers1

1

It would be:

switcher.setPressedHandler() { index in
    println("Did switch to index: \(index)")
}

Obviously, you must include the appropriate DVSwitch header in the project's bridging header.

Rob
  • 415,655
  • 72
  • 787
  • 1,044