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