Add availability check for iOS 8 and OS X 10.10 methods.

- `NSLayoutConstraint.activateConstraints(_:)`
- `NSLayoutConstraint.deactivateConstraints(_:)`
This commit is contained in:
Suyeol Jeon 2015-09-18 13:18:28 +09:00
parent 8e6219ef86
commit ba03f22eb8
1 changed files with 13 additions and 13 deletions

View File

@ -138,25 +138,25 @@ internal class ConcreteConstraint: Constraint {
}
internal override func activate() -> Void {
if NSLayoutConstraint.respondsToSelector("activateConstraints:") && self.installInfo != nil {
guard #available(iOS 8.0, OSX 10.10, *), self.installInfo != nil else {
self.install()
return
}
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
if layoutConstraints.count > 0 {
NSLayoutConstraint.activateConstraints(layoutConstraints)
}
} else {
self.install()
}
}
internal override func deactivate() -> Void {
if NSLayoutConstraint.respondsToSelector("deactivateConstraints:") && self.installInfo != nil {
guard #available(iOS 8.0, OSX 10.10, *), self.installInfo != nil else {
self.install()
return
}
let layoutConstraints = self.installInfo!.layoutConstraints.allObjects as! [LayoutConstraint]
if layoutConstraints.count > 0 {
NSLayoutConstraint.deactivateConstraints(layoutConstraints)
}
} else {
self.uninstall()
}
}
private let fromItem: ConstraintItem