Adds workarounds for compiler bugs.
This commit is contained in:
parent
ba2787c3cb
commit
b08bf24201
|
|
@ -52,7 +52,14 @@ extension UIControl {
|
|||
return ControlEvent(events: source)
|
||||
}
|
||||
|
||||
static func rx_value<C: UIControl, T: Equatable>(control: C, getter: (C) -> T, setter: (C, T) -> Void) -> ControlProperty<T> {
|
||||
/**
|
||||
You might be wondering why the ugly `as!` casts etc, well, for some reason if
|
||||
Swift compiler knows C is UIControl type and optimizations are turned on, it will crash.
|
||||
|
||||
Can somebody offer poor Swift compiler writers some other better job maybe, this is becoming
|
||||
rediculous.
|
||||
*/
|
||||
static func rx_value<C: AnyObject, T: Equatable>(control: C, getter: (C) -> T, setter: (C, T) -> Void) -> ControlProperty<T> {
|
||||
let source: Observable<T> = Observable.create { [weak weakControl = control] observer in
|
||||
guard let control = weakControl else {
|
||||
observer.on(.Completed)
|
||||
|
|
@ -61,7 +68,7 @@ extension UIControl {
|
|||
|
||||
observer.on(.Next(getter(control)))
|
||||
|
||||
let controlTarget = ControlTarget(control: control, controlEvents: [.AllEditingEvents, .ValueChanged]) { _ in
|
||||
let controlTarget = ControlTarget(control: control as! UIControl, controlEvents: [.AllEditingEvents, .ValueChanged]) { _ in
|
||||
if let control = weakControl {
|
||||
observer.on(.Next(getter(control)))
|
||||
}
|
||||
|
|
@ -72,7 +79,7 @@ extension UIControl {
|
|||
}
|
||||
}
|
||||
.distinctUntilChanged()
|
||||
.takeUntil(control.rx_deallocated)
|
||||
.takeUntil((control as! NSObject).rx_deallocated)
|
||||
|
||||
let bindingObserver = UIBindingObserver(UIElement: control, binding: setter)
|
||||
|
||||
|
|
|
|||
|
|
@ -403,6 +403,7 @@
|
|||
C8DF92EB1B0B38C0009BCF9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C8DF92E91B0B38C0009BCF9A /* Images.xcassets */; };
|
||||
C8E9D2AF1BD3FD960079D0DB /* ActivityIndicator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C80397391BD3E17D009D8B26 /* ActivityIndicator.swift */; };
|
||||
C8F3FFF11C6FD2FA00E60EEC /* UIApplication+Rx.swift in Sources */ = {isa = PBXBuildFile; fileRef = E3EE18D11C4D68F900834224 /* UIApplication+Rx.swift */; };
|
||||
C8F3FFF51C6FD62E00E60EEC /* UIBindingObserver.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8F3FFF41C6FD62E00E60EEC /* UIBindingObserver.swift */; };
|
||||
C8F6A12B1BEF9DA3007DF367 /* ConcurrentDispatchQueueScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C894648E1BC6C2B00055219D /* ConcurrentDispatchQueueScheduler.swift */; };
|
||||
C8F6A12C1BEF9DA3007DF367 /* ConcurrentMainScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C8B145051BD2E45200267DCE /* ConcurrentMainScheduler.swift */; };
|
||||
C8F6A12D1BEF9DA3007DF367 /* CurrentThreadScheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = C894648F1BC6C2B00055219D /* CurrentThreadScheduler.swift */; };
|
||||
|
|
@ -922,6 +923,7 @@
|
|||
C8DF92E91B0B38C0009BCF9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
|
||||
C8DF92F01B0B3E67009BCF9A /* Info-OSX.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-OSX.plist"; sourceTree = "<group>"; };
|
||||
C8DF92F21B0B3E71009BCF9A /* Info-iOS.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Info-iOS.plist"; sourceTree = "<group>"; };
|
||||
C8F3FFF41C6FD62E00E60EEC /* UIBindingObserver.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIBindingObserver.swift; sourceTree = "<group>"; };
|
||||
C8F6A1361BEF9DD4007DF367 /* RetryWhen.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = RetryWhen.swift; sourceTree = "<group>"; };
|
||||
C8F8C4891C277F460047640B /* CalculatorState.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalculatorState.swift; sourceTree = "<group>"; };
|
||||
C8F8C49C1C277F4F0047640B /* CalculatorAction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CalculatorAction.swift; sourceTree = "<group>"; };
|
||||
|
|
@ -1547,6 +1549,7 @@
|
|||
C89465171BC6C2BC0055219D /* CocoaUnits */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C8F3FFF41C6FD62E00E60EEC /* UIBindingObserver.swift */,
|
||||
C80DDEC11BCE9041006A1832 /* Driver */,
|
||||
C89465191BC6C2BC0055219D /* ControlEvent.swift */,
|
||||
C894651B1BC6C2BC0055219D /* ControlProperty.swift */,
|
||||
|
|
@ -2242,6 +2245,7 @@
|
|||
C8F6A1311BEF9DA3007DF367 /* OperationQueueScheduler.swift in Sources */,
|
||||
CBEE77541BD8C7B700AD584C /* ToArray.swift in Sources */,
|
||||
C89465771BC6C2BC0055219D /* NSNotificationCenter+Rx.swift in Sources */,
|
||||
C8F3FFF51C6FD62E00E60EEC /* UIBindingObserver.swift in Sources */,
|
||||
C89465091BC6C2B00055219D /* ReplaySubject.swift in Sources */,
|
||||
C8BCD3E01C1480E9005F1280 /* Operators.swift in Sources */,
|
||||
C84CC58E1BDD486300E06A64 /* SynchronizedSubscribeType.swift in Sources */,
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@
|
|||
</AdditionalOptions>
|
||||
</TestAction>
|
||||
<LaunchAction
|
||||
buildConfiguration = "Debug"
|
||||
buildConfiguration = "Release"
|
||||
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
|
||||
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
|
||||
launchStyle = "0"
|
||||
|
|
|
|||
Loading…
Reference in New Issue