0

协议声明:

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

用法:

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

                    }
                }
            }
        }
    }

如何检查 var 实现以及如何分配?

4

0 回答 0