Skip to content

Commit

Permalink
Changed rex_text bindable property to be an optional string
Browse files Browse the repository at this point in the history
  • Loading branch information
dmcrodrigues committed Jul 2, 2016
1 parent 265e8e9 commit 82bccfd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 3 deletions.
5 changes: 3 additions & 2 deletions Source/UIKit/UILabel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import UIKit

extension UILabel {
/// Wraps a label's `text` value in a bindable property.
public var rex_text: MutableProperty<String> {
return associatedProperty(self, keyPath: "text")
public var rex_text: MutableProperty<String?> {
return associatedProperty(self, key: &attributedTextKey, initial: { $0.text }, setter: { $0.text = $1 })
}

/// Wraps a label's `attributedText` value in a bindable property.
Expand All @@ -26,5 +26,6 @@ extension UILabel {
}
}

private var textKey: UInt8 = 0
private var attributedTextKey: UInt8 = 0
private var textColorKey: UInt8 = 0
2 changes: 1 addition & 1 deletion Tests/UIKit/UILabelTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class UILabelTests: XCTestCase {
label.text = ""

let (pipeSignal, observer) = Signal<String, NoError>.pipe()
label.rex_text <~ SignalProducer(signal: pipeSignal)
label.rex_text <~ SignalProducer(signal: pipeSignal).producer.map(Optional.init) // TODO: Remove in the future, binding with optionals will be available soon in RAC

observer.sendNext(firstChange)
XCTAssertEqual(label.text, firstChange)
Expand Down
1 change: 1 addition & 0 deletions Tests/UIKit/UITableViewCellTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class UITableViewCellTests: XCTestCase {
label.rex_text <~
titleProperty
.producer
.map(Optional.init) // TODO: Remove in the future, binding with optionals will be available soon in RAC
.takeUntil(cell.rex_prepareForReuse)

XCTAssertEqual(label.text, "John")
Expand Down

0 comments on commit 82bccfd

Please sign in to comment.