0

protocol declaration:

@objc protocol LeftSideMenuViewControllerProtocol {
    var containerShouldPerformContentSegueWithIdentifier:((segueIdentifier: String, object: AnyObject!) -> Void)! {set get}
    optional var containerShouldResizeLeftMenuToValue:((CGFloat) -> Void)! {set get}
}

usage:

override var leftEmbedNavigation: CommonNavigationController? {
        willSet{
            if let nav = newValue {
                if let vc = nav.viewControllers[0] as? LeftSideMenuViewControllerProtocol {
// non optional var, all good
                    vc.containerShouldPerformContentSegueWithIdentifier = {
                        [weak self] (segueIdentifier: String, object: AnyObject!) in

                    }
// optional declaration, cannot assign
                    vc.containerShouldResizeLeftMenuToValue = { [weak self] (newConstraintValue) in

                    }
                }
            }
        }
    }

How do I check var implemented and how do I assign on?

iiFreeman
  • 5,165
  • 2
  • 29
  • 42
  • Why are you using variables instead of proper delegate methods? – akashivskyy Aug 28 '14 at 12:04
  • @akashivskyy using closures/blocks much more efficient, readable and useful from my point. In Objective-C task like that solves so easy, could not understand why do protocols has "optional" method and var if there is not documented way to work with? – iiFreeman Aug 28 '14 at 12:07
  • 1
    As for now, you cannot assign to a protocol's optional variable (it may be a bug). You can follow [the related ADF thread](https://devforums.apple.com/message/995076) if you want. – akashivskyy Aug 28 '14 at 12:31

0 Answers0