mirror of https://github.com/SnapKit/SnapKit
Fix up debug labels accessors
This commit is contained in:
parent
46c02e3cc9
commit
de00f5e87e
|
@ -30,19 +30,19 @@
|
||||||
|
|
||||||
public protocol ConstraintDSL {
|
public protocol ConstraintDSL {
|
||||||
|
|
||||||
var label: String? { get set }
|
|
||||||
var target: AnyObject? { get }
|
var target: AnyObject? { get }
|
||||||
|
|
||||||
|
func setLabel(_ value: String?)
|
||||||
|
func label() -> String?
|
||||||
|
|
||||||
}
|
}
|
||||||
extension ConstraintDSL {
|
extension ConstraintDSL {
|
||||||
|
|
||||||
public var label: String? {
|
public func setLabel(_ value: String?) {
|
||||||
get {
|
objc_setAssociatedObject(self.target, &labelKey, value, .OBJC_ASSOCIATION_COPY_NONATOMIC)
|
||||||
return objc_getAssociatedObject(self.target, &labelKey) as? String
|
}
|
||||||
}
|
public func label() -> String? {
|
||||||
set {
|
return objc_getAssociatedObject(self.target, &labelKey) as? String
|
||||||
objc_setAssociatedObject(self.target, &labelKey, newValue, .OBJC_ASSOCIATION_COPY_NONATOMIC)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -144,7 +144,7 @@ private func descriptionForObject(_ object: AnyObject) -> String {
|
||||||
desc += type(of: object).description()
|
desc += type(of: object).description()
|
||||||
|
|
||||||
if let object = object as? ConstraintView {
|
if let object = object as? ConstraintView {
|
||||||
desc += ":\(object.snp.label ?? pointerDescription)"
|
desc += ":\(object.snp.label() ?? pointerDescription)"
|
||||||
} else if let object = object as? LayoutConstraint {
|
} else if let object = object as? LayoutConstraint {
|
||||||
desc += ":\(object.label ?? pointerDescription)"
|
desc += ":\(object.label ?? pointerDescription)"
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -490,4 +490,8 @@ class SnapKitTests: XCTestCase {
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
func testCanSetLabel() {
|
||||||
|
self.container.snp.setLabel("Hello World")
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue