From f4ee8f737f6aa86b87f5c285a2524f5381278f25 Mon Sep 17 00:00:00 2001 From: Syo Ikeda Date: Mon, 21 Sep 2015 16:44:17 +0900 Subject: [PATCH] Remove workarounds for compiler warning about StaticString The compiler warning disappears in Xcode 7. --- Source/Foundation/Association.swift | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/Source/Foundation/Association.swift b/Source/Foundation/Association.swift index 3b5e2d9..f301bbf 100644 --- a/Source/Foundation/Association.swift +++ b/Source/Foundation/Association.swift @@ -17,13 +17,11 @@ import ReactiveCocoa /// This can be used as an alternative to `DynamicProperty` for creating strongly typed /// bindings on Cocoa objects. public func associatedProperty(host: AnyObject, keyPath: StaticString) -> MutableProperty { - // Workaround compiler warning when using keyPath.stringValue - let key = "\(keyPath)" let initial: () -> String = { [weak host] _ in - host?.valueForKeyPath(key) as? String ?? "" + host?.valueForKeyPath(keyPath.stringValue) as? String ?? "" } let setter: String -> () = { [weak host] newValue in - host?.setValue(newValue, forKeyPath: key) + host?.setValue(newValue, forKeyPath: keyPath.stringValue) } return associatedProperty(host, key: keyPath.utf8Start, initial: initial, setter: setter) } @@ -39,13 +37,11 @@ public func associatedProperty(host: AnyObject, keyPath: StaticString) -> Mutabl /// N.B. Ensure that `host` isn't strongly captured by `placeholder`, otherwise this will /// create a retain cycle with `host` causing it to never dealloc. public func associatedProperty(host: AnyObject, keyPath: StaticString, placeholder: () -> T) -> MutableProperty { - // Workaround compiler warning when using keyPath.stringValue - let key = "\(keyPath)" let initial: () -> T = { [weak host] _ in - host?.valueForKeyPath(key) as? T ?? placeholder() + host?.valueForKeyPath(keyPath.stringValue) as? T ?? placeholder() } let setter: T -> () = { [weak host] newValue in - host?.setValue(newValue, forKeyPath: key) + host?.setValue(newValue, forKeyPath: keyPath.stringValue) } return associatedProperty(host, key: keyPath.utf8Start, initial: initial, setter: setter) }