 
 public extension UIView {
 
-    func pinToSuperview(edges: [EdgeAnchor] = EdgeAnchor.allSides, relation: NSLayoutRelation = .Equal, activate: Bool = true) -> [NSLayoutConstraint] {
+    func pinToSuperview(edges: [EdgeAnchor] = EdgeAnchor.allSides, relation: NSLayoutRelation = .equal, activate: Bool = true) -> [NSLayoutConstraint] {
         if let superview = self.superview {
-            return self.pinToView(superview, edges: edges, activate: activate)
+            return self.pinToView(view: superview, edges: edges, activate: activate)
         } else {
             fatalError("Cannot pin to a nil superview")
         }
     }
 
-    func pinToView(view: UIView, edges: [EdgeAnchor] = EdgeAnchor.allSides, relation: NSLayoutRelation = .Equal, activate: Bool = true) -> [NSLayoutConstraint] {
-        let addConstraint: (edge: EdgeAnchor) -> NSLayoutConstraint? = { edge in
+    func pinToView(view: UIView, edges: [EdgeAnchor] = EdgeAnchor.allSides, relation: NSLayoutRelation = .equal, activate: Bool = true) -> [NSLayoutConstraint] {
+        let addConstraint: (_ edge: EdgeAnchor) -> NSLayoutConstraint? = { edge in
             if edges.contains(edge) {
                 let constant: CGFloat
                 let priority: UILayoutPriority
 
-                if let index = edges.indexOf(edge) {
+                if let index = edges.index(of: edge) {
                     let currentEdge = edges[index]
                     constant = currentEdge.constant
                     priority = currentEdge.priority

public extension NSLayoutConstraint {

    static func activateAllConstraints(constraints: [[NSLayoutConstraint]]) {
        NSLayoutConstraint.activateConstraints(constraints.flatMap { $0 })
    }

    static func deactivateAllConstraints(constraints: [[NSLayoutConstraint]]) {
        NSLayoutConstraint.deactivateConstraints(constraints.flatMap { $0 })
    }

}


// MARK: Objective-C API

public extension UIView {

    @available(*, unavailable, message="Only to be used from Objective-C") func objc_pinToView(view: UIView, inset: UIEdgeInsets = UIEdgeInsetsZero) -> [NSLayoutConstraint] {
        return self._objcPinToView(view)
    }

    @available(*, unavailable, message="Only to be used from Objective-C") func objc_pinToSuperview(inset: UIEdgeInsets = UIEdgeInsetsZero) -> [NSLayoutConstraint] {
        if let superview = self.superview {
            return self._objcPinToView(superview, inset: inset)
        } else {
            fatalError("Cannot pin to a nil superview")
        }
    }

}



    func setActive(active: Bool) {
        if active {
            NSLayoutConstraint.activate(self)
        } else {
            NSLayoutConstraint.deactivate(self)
        }
    }

}
