0

I'm trying to use a control called MZFormSheetController in swift. In the example given it provides a property as a completion handler, if I understand correctly, but I'm having difficulties translating it in Swift. Any help would be appreciated.

This is in the obj-c example.

controller.didPresentContentViewControllerHandler = ^(UIViewController *content) {
    NSLog(@"DID PRESENT");
    [self setNeedsStatusBarAppearanceUpdate];
};

I tried many variations and did an extensive search in the web but I could not find anything that could help me so I'm stuck here

controller.didPresentContentViewControllerHandler = (content:UIViewController() -> () {
    println("did present1")
})

Here are the relevant docs: Cocoa Docs:: MZFormSheetPresentationController:: didPresentContentViewControllerHandler

Juan Catalan
  • 2,299
  • 1
  • 17
  • 23
snksnk
  • 1,566
  • 4
  • 21
  • 46

2 Answers2

2

If you need to access the view controller then do it like this,

controller.didPresentContentViewControllerHandler = {
    controller in
    println("did present1")
}

Or if you dont need the reference to the view controller, you can simply do,

let controller = Controller()
controller.didPresentContentViewControllerHandler = {
    _ in
     println("did present1")
}
Sandeep
  • 20,908
  • 7
  • 66
  • 106
1

Try add a variable after opening brace

controller.didPresentContentViewControllerHandler = {
    vc in
    println("did present1")
})
Mr. Polywhirl
  • 42,981
  • 12
  • 84
  • 132
Greg
  • 25,317
  • 6
  • 53
  • 62