Skip to content

Commit

Permalink
Merge pull request #68 from ikesyo/refactor-rex_valueProperty
Browse files Browse the repository at this point in the history
Refactor NSObject.rex_valueProperty() using associatedProperty()
  • Loading branch information
neilpa committed Nov 24, 2015
2 parents e046279 + b413164 commit 9b0209a
Showing 1 changed file with 1 addition and 5 deletions.
6 changes: 1 addition & 5 deletions Source/Foundation/NSObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ extension NSObject {
/// N.B. Ensure that `self` isn't strongly captured by `initial` or `setter`, otherwise this
/// will create a retain cycle causing `self` to never dealloc.
public func rex_valueProperty<T>(key: UnsafePointer<()>, _ initial: () -> T, _ setter: T -> ()) -> MutableProperty<T> {
return associatedObject(self, key: key) {
let property = MutableProperty(initial())
property.producer.start(Observer(next: setter))
return property
}
return associatedProperty(self, key: key, initial: initial, setter: setter)
}
}

0 comments on commit 9b0209a

Please sign in to comment.