Initialize with positional constants

suggest change

This is Swift 2 ("action" and .TouchUpInside). It has to run in a method where self and view already exist. It does not work as a stored-property initializer. The "action" method must exist.

let mySwitch: UISwitch = {
    view.addSubview($0)
    $0.addTarget(self, action: "action", forControlEvents: .TouchUpInside)
    return $0
}(UISwitch())

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents