diff --git a/.travis.yml b/.travis.yml index 47dd0d1..180d784 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: objective-c matrix: include: - - osx_image: xcode7.3 + - osx_image: xcode8 env: global: diff --git a/Cartfile b/Cartfile index fb56d4c..87745f3 100644 --- a/Cartfile +++ b/Cartfile @@ -1 +1 @@ -github "ReactiveCocoa/ReactiveCocoa" ~> 4.2.1 +github "ReactiveCocoa/ReactiveCocoa" "RAC5-swift3" diff --git a/Cartfile.resolved b/Cartfile.resolved index 421a6de..a3bf652 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "antitypical/Result" "2.1.1" -github "ReactiveCocoa/ReactiveCocoa" "v4.2.1" +github "antitypical/Result" "2fe88d1d41615ed060489e8cd06fc1b3e8f0ca53" +github "ReactiveCocoa/ReactiveCocoa" "3073a487acd53008a41b89ef6512040a1347212d" diff --git a/Deprecations+Removals.swift b/Deprecations+Removals.swift new file mode 100644 index 0000000..5be18a9 --- /dev/null +++ b/Deprecations+Removals.swift @@ -0,0 +1,45 @@ +// MARK: Renamed APIs in Swift 3.0 +import ReactiveCocoa +import enum Result.NoError + +extension SignalProtocol { + @available(*, unavailable, renamed:"mute(for:clock:)") + public func muteFor(_ interval: TimeInterval, clock: DateSchedulerProtocol) -> Signal { fatalError() } + + @available(*, unavailable, renamed:"timeout(after:with:on:)") + public func timeoutAfter(_ interval: TimeInterval, withEvent event: Event, onScheduler scheduler: DateSchedulerProtocol) -> Signal { fatalError() } +} + +extension SignalProducerProtocol { + @available(*, unavailable, renamed:"mute(for:clock:)") + public func muteFor(_ interval: TimeInterval, clock: DateSchedulerProtocol) -> SignalProducer { fatalError() } + + @available(*, unavailable, renamed:"timeout(after:with:on:)") + public func timeoutAfter(_ interval: TimeInterval, withEvent event: Event, onScheduler scheduler: DateSchedulerProtocol) -> SignalProducer { fatalError() } + + @available(*, unavailable, renamed:"group(by:)") + public func groupBy(_ grouping: (Value) -> Key) -> SignalProducer<(Key, SignalProducer), Error> { fatalError() } + + @available(*, unavailable, renamed:"defer(by:on:)") + public func deferred(_ interval: TimeInterval, onScheduler scheduler: DateSchedulerProtocol) -> SignalProducer { fatalError() } +} + +extension UserDefaults { + @available(*, unavailable, renamed:"rex_value(forKey:)") + public func rex_valueForKey(_ key: String) -> SignalProducer { fatalError() } +} + +extension NSObject { + @available(*, unavailable, renamed:"rex_producer(forKeyPath:)") + public func rex_producerForKeyPath(_ keyPath: String) -> SignalProducer { fatalError() } +} + +extension Data { + @available(*, unavailable, renamed:"rex_data(contentsOf:options:)") + public static func rex_dataWithContentsOfURL(_ url: URL, options: Data.ReadingOptions = []) -> SignalProducer { fatalError() } +} + +extension NSData { + @available(*, unavailable, renamed:"rex_data(contentsOf:options:)") + public static func rex_dataWithContentsOfURL(_ url: URL, options: NSData.ReadingOptions = []) -> SignalProducer { fatalError() } +} diff --git a/Rex.xcodeproj/project.pbxproj b/Rex.xcodeproj/project.pbxproj index a043fc4..ac0fbc8 100644 --- a/Rex.xcodeproj/project.pbxproj +++ b/Rex.xcodeproj/project.pbxproj @@ -39,6 +39,14 @@ 8295FD871B87309F007C9000 /* UIControlTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8295FD851B873081007C9000 /* UIControlTests.swift */; }; 8295FD8A1B87352D007C9000 /* UIButtonTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8295FD881B873490007C9000 /* UIButtonTests.swift */; }; 8295FD8D1B87374A007C9000 /* UIBarButtonItemTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8295FD8B1B873748007C9000 /* UIBarButtonItemTests.swift */; }; + 9A5492121D33387D009A8D44 /* Deprecations+Removals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A5492111D33387D009A8D44 /* Deprecations+Removals.swift */; }; + 9A5492131D33387D009A8D44 /* Deprecations+Removals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A5492111D33387D009A8D44 /* Deprecations+Removals.swift */; }; + 9A5492141D33387D009A8D44 /* Deprecations+Removals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A5492111D33387D009A8D44 /* Deprecations+Removals.swift */; }; + 9A5492151D33387D009A8D44 /* Deprecations+Removals.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A5492111D33387D009A8D44 /* Deprecations+Removals.swift */; }; + 9A54921C1D33400A009A8D44 /* Bindings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A54921B1D33400A009A8D44 /* Bindings.swift */; }; + 9A54921D1D334010009A8D44 /* Bindings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A54921B1D33400A009A8D44 /* Bindings.swift */; }; + 9A54921E1D334011009A8D44 /* Bindings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A54921B1D33400A009A8D44 /* Bindings.swift */; }; + 9A54921F1D334012009A8D44 /* Bindings.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9A54921B1D33400A009A8D44 /* Bindings.swift */; }; 9DA915A41CA6301C003723B9 /* UIDatePicker.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DA915A31CA6301C003723B9 /* UIDatePicker.swift */; }; 9DA915A61CA63046003723B9 /* UIDatePickerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DA915A51CA63046003723B9 /* UIDatePickerTests.swift */; }; C72CF3E51CBF188A00E19897 /* RACSignal.swift in Sources */ = {isa = PBXBuildFile; fileRef = C72CF3E41CBF188A00E19897 /* RACSignal.swift */; }; @@ -56,8 +64,8 @@ CC02C18B1CCA704F0025CC04 /* ActionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC02C1881CCA704C0025CC04 /* ActionTests.swift */; }; CC02C18C1CCA704F0025CC04 /* ActionTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC02C1881CCA704C0025CC04 /* ActionTests.swift */; }; D8003E941AFEC3D400D7D3C5 /* Rex.h in Headers */ = {isa = PBXBuildFile; fileRef = D8003E931AFEC3D400D7D3C5 /* Rex.h */; settings = {ATTRIBUTES = (Public, ); }; }; - D8003EB41AFEC6B000D7D3C5 /* ReactiveCocoa.framework in (null) */ = {isa = PBXBuildFile; fileRef = D8003EAD1AFEC68A00D7D3C5 /* ReactiveCocoa.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - D8003EB51AFEC6B000D7D3C5 /* Result.framework in (null) */ = {isa = PBXBuildFile; fileRef = D8003EAE1AFEC68A00D7D3C5 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + D8003EB41AFEC6B000D7D3C5 /* ReactiveCocoa.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = D8003EAD1AFEC68A00D7D3C5 /* ReactiveCocoa.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + D8003EB51AFEC6B000D7D3C5 /* Result.framework in Copy Files */ = {isa = PBXBuildFile; fileRef = D8003EAE1AFEC68A00D7D3C5 /* Result.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; D8003EB91AFEC7A900D7D3C5 /* SignalProducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8003EB81AFEC7A900D7D3C5 /* SignalProducer.swift */; }; D8003EBD1AFED01000D7D3C5 /* Signal.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8003EBC1AFED01000D7D3C5 /* Signal.swift */; }; D8003EC21AFED30F00D7D3C5 /* SignalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8003EBE1AFED2F800D7D3C5 /* SignalTests.swift */; }; @@ -71,8 +79,8 @@ D83457331AFEE4930070616A /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8003EAE1AFEC68A00D7D3C5 /* Result.framework */; }; D83457351AFEE4B20070616A /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8003EC91AFEE3ED00D7D3C5 /* ReactiveCocoa.framework */; }; D83457361AFEE4B20070616A /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8003ECA1AFEE3ED00D7D3C5 /* Result.framework */; }; - D83457391AFEE4BE0070616A /* ReactiveCocoa.framework in (null) */ = {isa = PBXBuildFile; fileRef = D8003EC91AFEE3ED00D7D3C5 /* ReactiveCocoa.framework */; }; - D834573A1AFEE4BE0070616A /* Result.framework in (null) */ = {isa = PBXBuildFile; fileRef = D8003ECA1AFEE3ED00D7D3C5 /* Result.framework */; }; + D83457391AFEE4BE0070616A /* ReactiveCocoa.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8003EC91AFEE3ED00D7D3C5 /* ReactiveCocoa.framework */; }; + D834573A1AFEE4BE0070616A /* Result.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8003ECA1AFEE3ED00D7D3C5 /* Result.framework */; }; D834573C1AFEE57E0070616A /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8003EC91AFEE3ED00D7D3C5 /* ReactiveCocoa.framework */; }; D834573D1AFEE57E0070616A /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8003ECA1AFEE3ED00D7D3C5 /* Result.framework */; }; D83457411AFEE6050070616A /* SignalTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8003EBE1AFED2F800D7D3C5 /* SignalTests.swift */; }; @@ -90,9 +98,9 @@ D8715DA11C211011005F4191 /* Rex.h in Headers */ = {isa = PBXBuildFile; fileRef = D8003E931AFEC3D400D7D3C5 /* Rex.h */; settings = {ATTRIBUTES = (Public, ); }; }; D8715DA21C211014005F4191 /* Rex.h in Headers */ = {isa = PBXBuildFile; fileRef = D8003E931AFEC3D400D7D3C5 /* Rex.h */; settings = {ATTRIBUTES = (Public, ); }; }; D8715DA31C21107F005F4191 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FFBD01B34AD6F001A89B3 /* Association.swift */; }; - D8715DA41C21107F005F4191 /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973A1B17F2F7002E15BA /* NSData.swift */; }; + D8715DA41C21107F005F4191 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973A1B17F2F7002E15BA /* Data.swift */; }; D8715DA51C21107F005F4191 /* NSObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F097431B17F3C8002E15BA /* NSObject.swift */; }; - D8715DA61C21107F005F4191 /* NSUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973C1B17F30D002E15BA /* NSUserDefaults.swift */; }; + D8715DA61C21107F005F4191 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973C1B17F30D002E15BA /* UserDefaults.swift */; }; D8715DA91C2110DA005F4191 /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8715DA71C2110DA005F4191 /* ReactiveCocoa.framework */; }; D8715DAA1C2110DA005F4191 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8715DA81C2110DA005F4191 /* Result.framework */; }; D8715DB91C2112A9005F4191 /* Rex.h in Headers */ = {isa = PBXBuildFile; fileRef = D8003E931AFEC3D400D7D3C5 /* Rex.h */; settings = {ATTRIBUTES = (Public, ); }; }; @@ -101,9 +109,9 @@ D8715DBC1C2112D1005F4191 /* Signal.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8003EBC1AFED01000D7D3C5 /* Signal.swift */; }; D8715DBD1C2112D1005F4191 /* SignalProducer.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8003EB81AFEC7A900D7D3C5 /* SignalProducer.swift */; }; D8715DBE1C2112D6005F4191 /* Association.swift in Sources */ = {isa = PBXBuildFile; fileRef = D86FFBD01B34AD6F001A89B3 /* Association.swift */; }; - D8715DBF1C2112D6005F4191 /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973A1B17F2F7002E15BA /* NSData.swift */; }; + D8715DBF1C2112D6005F4191 /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973A1B17F2F7002E15BA /* Data.swift */; }; D8715DC01C2112D6005F4191 /* NSObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F097431B17F3C8002E15BA /* NSObject.swift */; }; - D8715DC11C2112D6005F4191 /* NSUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973C1B17F30D002E15BA /* NSUserDefaults.swift */; }; + D8715DC11C2112D6005F4191 /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973C1B17F30D002E15BA /* UserDefaults.swift */; }; D8715DC41C211310005F4191 /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8715DC21C211310005F4191 /* ReactiveCocoa.framework */; }; D8715DC51C211310005F4191 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8715DC31C211310005F4191 /* Result.framework */; }; D8715DC61C211553005F4191 /* UIBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5173EBC71B625A6800C9B48E /* UIBarButtonItem.swift */; }; @@ -125,8 +133,8 @@ D8715DE51C211643005F4191 /* UIViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8289A2E61BD7F7730097FB60 /* UIViewTests.swift */; }; D8715DE61C21170C005F4191 /* ReactiveCocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8715DC21C211310005F4191 /* ReactiveCocoa.framework */; }; D8715DE71C21170C005F4191 /* Result.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D8715DC31C211310005F4191 /* Result.framework */; }; - D8715DE91C211739005F4191 /* ReactiveCocoa.framework in (null) */ = {isa = PBXBuildFile; fileRef = D8715DC21C211310005F4191 /* ReactiveCocoa.framework */; }; - D8715DEA1C211739005F4191 /* Result.framework in (null) */ = {isa = PBXBuildFile; fileRef = D8715DC31C211310005F4191 /* Result.framework */; }; + D8715DE91C211739005F4191 /* ReactiveCocoa.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8715DC21C211310005F4191 /* ReactiveCocoa.framework */; }; + D8715DEA1C211739005F4191 /* Result.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = D8715DC31C211310005F4191 /* Result.framework */; }; D8A454061BD26A1A00C9E790 /* Property.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A454051BD26A1A00C9E790 /* Property.swift */; }; D8A454071BD26A1A00C9E790 /* Property.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A454051BD26A1A00C9E790 /* Property.swift */; }; D8A454091BD2772700C9E790 /* PropertyTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8A454081BD2772700C9E790 /* PropertyTests.swift */; }; @@ -134,18 +142,18 @@ D8E4A6201B7BBB1600EAD8A8 /* UIBarButtonItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5173EBC71B625A6800C9B48E /* UIBarButtonItem.swift */; }; D8E4A6211B7BBB2100EAD8A8 /* UIBarItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5173EBC51B625A2600C9B48E /* UIBarItem.swift */; }; D8F073161B863CE70047D546 /* UILabelTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F073141B861B3A0047D546 /* UILabelTests.swift */; }; - D8F0973B1B17F2F7002E15BA /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973A1B17F2F7002E15BA /* NSData.swift */; }; - D8F0973D1B17F30D002E15BA /* NSUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973C1B17F30D002E15BA /* NSUserDefaults.swift */; }; - D8F0973E1B17F30D002E15BA /* NSUserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973C1B17F30D002E15BA /* NSUserDefaults.swift */; }; - D8F0973F1B17F31E002E15BA /* NSData.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973A1B17F2F7002E15BA /* NSData.swift */; }; + D8F0973B1B17F2F7002E15BA /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973A1B17F2F7002E15BA /* Data.swift */; }; + D8F0973D1B17F30D002E15BA /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973C1B17F30D002E15BA /* UserDefaults.swift */; }; + D8F0973E1B17F30D002E15BA /* UserDefaults.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973C1B17F30D002E15BA /* UserDefaults.swift */; }; + D8F0973F1B17F31E002E15BA /* Data.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F0973A1B17F2F7002E15BA /* Data.swift */; }; D8F097441B17F3C8002E15BA /* NSObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F097431B17F3C8002E15BA /* NSObject.swift */; }; D8F097451B17F3C8002E15BA /* NSObject.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F097431B17F3C8002E15BA /* NSObject.swift */; }; + D8F0974A1B17F5E1002E15BA /* NSObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F097471B17F5DD002E15BA /* NSObjectTests.swift */; }; + D8F0974B1B17F5E2002E15BA /* NSObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F097471B17F5DD002E15BA /* NSObjectTests.swift */; }; E6933BEA1CD9C335006F7CE7 /* UIProgressViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6933BE81CD9C1F1006F7CE7 /* UIProgressViewTests.swift */; }; E6933BEB1CD9C363006F7CE7 /* UIProgressViewTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6933BE81CD9C1F1006F7CE7 /* UIProgressViewTests.swift */; }; E6933BEC1CD9C37D006F7CE7 /* UIProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6933BE61CD9C0B2006F7CE7 /* UIProgressView.swift */; }; E6933BED1CD9C37D006F7CE7 /* UIProgressView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E6933BE61CD9C0B2006F7CE7 /* UIProgressView.swift */; }; - D8F0974A1B17F5E1002E15BA /* NSObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F097471B17F5DD002E15BA /* NSObjectTests.swift */; }; - D8F0974B1B17F5E2002E15BA /* NSObjectTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = D8F097471B17F5DD002E15BA /* NSObjectTests.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -173,49 +181,50 @@ /* End PBXContainerItemProxy section */ /* Begin PBXCopyFilesBuildPhase section */ - D8003EB21AFEC6A800D7D3C5 /* (null) */ = { + D8003EB21AFEC6A800D7D3C5 /* Copy Files */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 16; files = ( - D8003EB41AFEC6B000D7D3C5 /* ReactiveCocoa.framework in (null) */, - D8003EB51AFEC6B000D7D3C5 /* Result.framework in (null) */, + D8003EB41AFEC6B000D7D3C5 /* ReactiveCocoa.framework in Copy Files */, + D8003EB51AFEC6B000D7D3C5 /* Result.framework in Copy Files */, ); + name = "Copy Files"; runOnlyForDeploymentPostprocessing = 0; }; - D83457371AFEE4B80070616A /* (null) */ = { + D83457371AFEE4B80070616A /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 16; files = ( - D83457391AFEE4BE0070616A /* ReactiveCocoa.framework in (null) */, - D834573A1AFEE4BE0070616A /* Result.framework in (null) */, + D83457391AFEE4BE0070616A /* ReactiveCocoa.framework in CopyFiles */, + D834573A1AFEE4BE0070616A /* Result.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; - D8715DE81C21172A005F4191 /* (null) */ = { + D8715DE81C21172A005F4191 /* CopyFiles */ = { isa = PBXCopyFilesBuildPhase; buildActionMask = 2147483647; dstPath = ""; dstSubfolderSpec = 16; files = ( - D8715DE91C211739005F4191 /* ReactiveCocoa.framework in (null) */, - D8715DEA1C211739005F4191 /* Result.framework in (null) */, + D8715DE91C211739005F4191 /* ReactiveCocoa.framework in CopyFiles */, + D8715DEA1C211739005F4191 /* Result.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 4238D5951B4D5950008534C0 /* NSTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = NSTextField.swift; path = AppKit/NSTextField.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 45CED46B1D27BB8700788BDC /* UIActivityIndicatorView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIActivityIndicatorView.swift; sourceTree = ""; }; 45CED46D1D27C1D400788BDC /* UIActivityIndicatorViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIActivityIndicatorViewTests.swift; sourceTree = ""; }; - 4238D5951B4D5950008534C0 /* NSTextField.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; name = NSTextField.swift; path = AppKit/NSTextField.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - 5B1C882D1D0715CE000B888F /* UISegmentedControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UISegmentedControl.swift; sourceTree = ""; }; - 5B1C882F1D071639000B888F /* UISegmentedControlTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UISegmentedControlTests.swift; sourceTree = ""; }; 5173EBC51B625A2600C9B48E /* UIBarItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UIBarItem.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 5173EBC71B625A6800C9B48E /* UIBarButtonItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UIBarButtonItem.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + 5B1C882D1D0715CE000B888F /* UISegmentedControl.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UISegmentedControl.swift; sourceTree = ""; }; + 5B1C882F1D071639000B888F /* UISegmentedControlTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UISegmentedControlTests.swift; sourceTree = ""; }; 7D0DABA91CCC381F00B6CD2B /* UIControl+EnableSendActionsForControlEvents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIControl+EnableSendActionsForControlEvents.swift"; sourceTree = ""; }; 7D2AA99A1CB6EFEB008AB5C9 /* UISwitch.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UISwitch.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 7D2AA99C1CB6F275008AB5C9 /* UISwitchTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UISwitchTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; @@ -233,6 +242,8 @@ 8295FD851B873081007C9000 /* UIControlTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UIControlTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 8295FD881B873490007C9000 /* UIButtonTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UIButtonTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 8295FD8B1B873748007C9000 /* UIBarButtonItemTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UIBarButtonItemTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + 9A5492111D33387D009A8D44 /* Deprecations+Removals.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "Deprecations+Removals.swift"; sourceTree = SOURCE_ROOT; }; + 9A54921B1D33400A009A8D44 /* Bindings.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Bindings.swift; sourceTree = ""; }; 9DA915A31CA6301C003723B9 /* UIDatePicker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UIDatePicker.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; 9DA915A51CA63046003723B9 /* UIDatePickerTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UIDatePickerTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; C72CF3E41CBF188A00E19897 /* RACSignal.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = RACSignal.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; @@ -273,12 +284,12 @@ D8A454051BD26A1A00C9E790 /* Property.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Property.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; D8A454081BD2772700C9E790 /* PropertyTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = PropertyTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; D8F073141B861B3A0047D546 /* UILabelTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UILabelTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - D8F0973A1B17F2F7002E15BA /* NSData.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = NSData.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; - E6933BE61CD9C0B2006F7CE7 /* UIProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIProgressView.swift; sourceTree = ""; }; - E6933BE81CD9C1F1006F7CE7 /* UIProgressViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIProgressViewTests.swift; sourceTree = ""; }; - D8F0973C1B17F30D002E15BA /* NSUserDefaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = NSUserDefaults.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + D8F0973A1B17F2F7002E15BA /* Data.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = Data.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + D8F0973C1B17F30D002E15BA /* UserDefaults.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = UserDefaults.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; D8F097431B17F3C8002E15BA /* NSObject.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = NSObject.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; D8F097471B17F5DD002E15BA /* NSObjectTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; lineEnding = 0; path = NSObjectTests.swift; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.swift; }; + E6933BE61CD9C0B2006F7CE7 /* UIProgressView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIProgressView.swift; sourceTree = ""; }; + E6933BE81CD9C1F1006F7CE7 /* UIProgressViewTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIProgressViewTests.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -371,11 +382,15 @@ D8003E9D1AFEC3D400D7D3C5 /* Tests */, D8003EAA1AFEC57200D7D3C5 /* Binaries */, ); + indentWidth = 4; sourceTree = ""; + tabWidth = 4; + usesTabs = 0; }; D8003E901AFEC3D400D7D3C5 /* Source */ = { isa = PBXGroup; children = ( + 9A54921B1D33400A009A8D44 /* Bindings.swift */, D86FFBD91B34B3F0001A89B3 /* Action.swift */, D8A454051BD26A1A00C9E790 /* Property.swift */, D8003EBC1AFED01000D7D3C5 /* Signal.swift */, @@ -386,6 +401,7 @@ D8F097391B17F2BF002E15BA /* Foundation */, D86FFBD31B34B0E2001A89B3 /* UIKit */, D8003E911AFEC3D400D7D3C5 /* Supporting Files */, + 9A5492111D33387D009A8D44 /* Deprecations+Removals.swift */, ); path = Source; sourceTree = ""; @@ -530,9 +546,9 @@ isa = PBXGroup; children = ( D86FFBD01B34AD6F001A89B3 /* Association.swift */, - D8F0973A1B17F2F7002E15BA /* NSData.swift */, + D8F0973A1B17F2F7002E15BA /* Data.swift */, D8F097431B17F3C8002E15BA /* NSObject.swift */, - D8F0973C1B17F30D002E15BA /* NSUserDefaults.swift */, + D8F0973C1B17F30D002E15BA /* UserDefaults.swift */, ); path = Foundation; sourceTree = ""; @@ -608,7 +624,7 @@ D8003E951AFEC3D400D7D3C5 /* Sources */, D8003E961AFEC3D400D7D3C5 /* Frameworks */, D8003E971AFEC3D400D7D3C5 /* Resources */, - D8003EB21AFEC6A800D7D3C5 /* (null) */, + D8003EB21AFEC6A800D7D3C5 /* Copy Files */, ); buildRules = ( ); @@ -645,7 +661,7 @@ D834571A1AFEE44E0070616A /* Sources */, D834571B1AFEE44E0070616A /* Frameworks */, D834571C1AFEE44E0070616A /* Resources */, - D83457371AFEE4B80070616A /* (null) */, + D83457371AFEE4B80070616A /* CopyFiles */, ); buildRules = ( ); @@ -700,7 +716,7 @@ D8715DCD1C21160A005F4191 /* Sources */, D8715DCE1C21160A005F4191 /* Frameworks */, D8715DCF1C21160A005F4191 /* Resources */, - D8715DE81C21172A005F4191 /* (null) */, + D8715DE81C21172A005F4191 /* CopyFiles */, ); buildRules = ( ); @@ -719,7 +735,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0700; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Neil Pankey"; TargetAttributes = { D8003E8D1AFEC3D400D7D3C5 = { @@ -745,7 +761,7 @@ }; }; }; - buildConfigurationList = D8003E881AFEC3D400D7D3C5 /* Build configuration list for PBXProject "Rex-Mac" */; + buildConfigurationList = D8003E881AFEC3D400D7D3C5 /* Build configuration list for PBXProject "Rex" */; compatibilityVersion = "Xcode 3.2"; developmentRegion = English; hasScannedForEncodings = 0; @@ -828,13 +844,15 @@ C72CF3E51CBF188A00E19897 /* RACSignal.swift in Sources */, D8A454061BD26A1A00C9E790 /* Property.swift in Sources */, D86FFBDA1B34B3F0001A89B3 /* Action.swift in Sources */, + 9A5492121D33387D009A8D44 /* Deprecations+Removals.swift in Sources */, D86FFBD11B34AD6F001A89B3 /* Association.swift in Sources */, D8003EB91AFEC7A900D7D3C5 /* SignalProducer.swift in Sources */, D8003EBD1AFED01000D7D3C5 /* Signal.swift in Sources */, D8F097441B17F3C8002E15BA /* NSObject.swift in Sources */, - D8F0973B1B17F2F7002E15BA /* NSData.swift in Sources */, + D8F0973B1B17F2F7002E15BA /* Data.swift in Sources */, 4238D5961B4D5950008534C0 /* NSTextField.swift in Sources */, - D8F0973D1B17F30D002E15BA /* NSUserDefaults.swift in Sources */, + D8F0973D1B17F30D002E15BA /* UserDefaults.swift in Sources */, + 9A54921C1D33400A009A8D44 /* Bindings.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -857,6 +875,7 @@ 9DA915A41CA6301C003723B9 /* UIDatePicker.swift in Sources */, D86FFBD81B34B242001A89B3 /* UILabel.swift in Sources */, 7DCF5B331CC80D77004AEE75 /* UICollectionReusableView.swift in Sources */, + 9A54921D1D334010009A8D44 /* Bindings.swift in Sources */, D86FFBDB1B34B3F0001A89B3 /* Action.swift in Sources */, D86FFBD21B34AD7A001A89B3 /* Association.swift in Sources */, C7932E831C4B3F3000086F3C /* UITextField.swift in Sources */, @@ -864,7 +883,7 @@ 7DC325741CC6FCF100746D88 /* UITableViewCell.swift in Sources */, 5B7F81E31D0842AD0014B06D /* UISegmentedControl.swift in Sources */, 8289A2E31BD7EF740097FB60 /* UIImageView.swift in Sources */, - D8F0973E1B17F30D002E15BA /* NSUserDefaults.swift in Sources */, + D8F0973E1B17F30D002E15BA /* UserDefaults.swift in Sources */, D834572D1AFEE45B0070616A /* Signal.swift in Sources */, D8E4A6211B7BBB2100EAD8A8 /* UIBarItem.swift in Sources */, 7D2AA99B1CB6EFEB008AB5C9 /* UISwitch.swift in Sources */, @@ -879,8 +898,9 @@ C7DCE2B41CB3C89A001217D8 /* UITextView.swift in Sources */, 8289A2E51BD7F6DD0097FB60 /* UIView.swift in Sources */, D86FFBD61B34B116001A89B3 /* UIControl.swift in Sources */, - D8F0973F1B17F31E002E15BA /* NSData.swift in Sources */, + D8F0973F1B17F31E002E15BA /* Data.swift in Sources */, D86FFBDD1B34B691001A89B3 /* UIButton.swift in Sources */, + 9A5492131D33387D009A8D44 /* Deprecations+Removals.swift in Sources */, 45CED4711D27C1EB00788BDC /* UIActivityIndicatorView.swift in Sources */, 7D0DABAA1CCC381F00B6CD2B /* UIControl+EnableSendActionsForControlEvents.swift in Sources */, ); @@ -922,12 +942,14 @@ D8715D9E1C210FF9005F4191 /* Property.swift in Sources */, D8715DA01C210FF9005F4191 /* SignalProducer.swift in Sources */, D8715DA31C21107F005F4191 /* Association.swift in Sources */, + 9A54921F1D334012009A8D44 /* Bindings.swift in Sources */, D8715DA51C21107F005F4191 /* NSObject.swift in Sources */, D8715D9F1C210FF9005F4191 /* Signal.swift in Sources */, C72CF3E81CBF188A00E19897 /* RACSignal.swift in Sources */, - D8715DA41C21107F005F4191 /* NSData.swift in Sources */, + D8715DA41C21107F005F4191 /* Data.swift in Sources */, + 9A5492151D33387D009A8D44 /* Deprecations+Removals.swift in Sources */, D8715D9D1C210FF9005F4191 /* Action.swift in Sources */, - D8715DA61C21107F005F4191 /* NSUserDefaults.swift in Sources */, + D8715DA61C21107F005F4191 /* UserDefaults.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -938,7 +960,9 @@ D8715DBB1C2112D1005F4191 /* Property.swift in Sources */, D8715DCA1C211553005F4191 /* UILabel.swift in Sources */, 7DCF5B341CC80D78004AEE75 /* UICollectionReusableView.swift in Sources */, + 9A5492141D33387D009A8D44 /* Deprecations+Removals.swift in Sources */, D8715DCB1C211553005F4191 /* UIImageView.swift in Sources */, + 9A54921E1D334011009A8D44 /* Bindings.swift in Sources */, C7932E841C4B41E100086F3C /* UITextField.swift in Sources */, 7DBD48F41CC8141D0077AD4F /* Reusable.swift in Sources */, D8715DC61C211553005F4191 /* UIBarButtonItem.swift in Sources */, @@ -951,12 +975,12 @@ D8715DBC1C2112D1005F4191 /* Signal.swift in Sources */, C72CF3E71CBF188A00E19897 /* RACSignal.swift in Sources */, E6933BED1CD9C37D006F7CE7 /* UIProgressView.swift in Sources */, - D8715DBF1C2112D6005F4191 /* NSData.swift in Sources */, + D8715DBF1C2112D6005F4191 /* Data.swift in Sources */, D8715DCC1C211553005F4191 /* UIView.swift in Sources */, D8715DBA1C2112D1005F4191 /* Action.swift in Sources */, D8715DC81C211553005F4191 /* UIButton.swift in Sources */, D8715DC71C211553005F4191 /* UIBarItem.swift in Sources */, - D8715DC11C2112D6005F4191 /* NSUserDefaults.swift in Sources */, + D8715DC11C2112D6005F4191 /* UserDefaults.swift in Sources */, 45CED4721D27C1EC00788BDC /* UIActivityIndicatorView.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; @@ -1043,6 +1067,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; @@ -1083,6 +1108,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MACOSX_DEPLOYMENT_TARGET = 10.10; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = macosx; @@ -1109,7 +1135,6 @@ INFOPLIST_FILE = Source/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = "me.neilpa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; @@ -1135,10 +1160,10 @@ INFOPLIST_FILE = Source/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.9; PRODUCT_BUNDLE_IDENTIFIER = "me.neilpa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(PROJECT_NAME)"; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -1175,6 +1200,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks @loader_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "me.neilpa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; }; name = Release; }; @@ -1231,6 +1257,7 @@ PRODUCT_NAME = "$(PROJECT_NAME)"; SDKROOT = iphoneos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -1274,6 +1301,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "me.neilpa.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; VALIDATE_PRODUCT = YES; }; name = Release; @@ -1321,6 +1349,7 @@ PRODUCT_NAME = "$(PROJECT_NAME)"; SDKROOT = watchos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 4; VALIDATE_PRODUCT = YES; WATCHOS_DEPLOYMENT_TARGET = 2.0; @@ -1370,6 +1399,7 @@ PRODUCT_NAME = "$(PROJECT_NAME)"; SDKROOT = appletvos; SKIP_INSTALL = YES; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; @@ -1404,6 +1434,7 @@ PRODUCT_BUNDLE_IDENTIFIER = me.neilpa.RexTests; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; TVOS_DEPLOYMENT_TARGET = 9.0; VALIDATE_PRODUCT = YES; }; @@ -1412,7 +1443,7 @@ /* End XCBuildConfiguration section */ /* Begin XCConfigurationList section */ - D8003E881AFEC3D400D7D3C5 /* Build configuration list for PBXProject "Rex-Mac" */ = { + D8003E881AFEC3D400D7D3C5 /* Build configuration list for PBXProject "Rex" */ = { isa = XCConfigurationList; buildConfigurations = ( D8003EA21AFEC3D400D7D3C5 /* Debug */, diff --git a/Rex.xcodeproj/xcshareddata/xcschemes/Rex-Mac.xcscheme b/Rex.xcodeproj/xcshareddata/xcschemes/Rex-Mac.xcscheme index cc58cdc..3a84fae 100644 --- a/Rex.xcodeproj/xcshareddata/xcschemes/Rex-Mac.xcscheme +++ b/Rex.xcodeproj/xcshareddata/xcschemes/Rex-Mac.xcscheme @@ -1,6 +1,6 @@ { - return self.executing.signal + return self.isExecuting.signal .filterMap { $0 ? () : nil } } @@ -25,7 +25,7 @@ extension Action { public var rex_completed: Signal { return events .filterMap { event -> Void? in - if case .Completed = event { + if case .completed = event { return () } else { return nil @@ -43,11 +43,11 @@ extension CocoaAction { /// Creates a producer for the `enabled` state of a CocoaAction. public var rex_enabledProducer: SignalProducer { - return rex_producerForKeyPath("enabled") + return rex_producer(forKeyPath: #keyPath(CocoaAction.isEnabled)) } /// Creates a producer for the `executing` state of a CocoaAction. public var rex_executingProducer: SignalProducer { - return rex_producerForKeyPath("executing") + return rex_producer(forKeyPath: #keyPath(CocoaAction.isExecuting)) } } diff --git a/Source/AppKit/NSTextField.swift b/Source/AppKit/NSTextField.swift index cf14eee..4f2ba98 100644 --- a/Source/AppKit/NSTextField.swift +++ b/Source/AppKit/NSTextField.swift @@ -13,8 +13,8 @@ import enum Result.NoError extension NSTextField { /// Sends the field's string value whenever it changes. public var rex_textSignal: SignalProducer { - return NSNotificationCenter.defaultCenter() - .rac_notifications(NSControlTextDidChangeNotification, object: self) + return NotificationCenter.default + .rac_notifications(forName: .NSControlTextDidChange, object: self) .map { notification in (notification.object as! NSTextField).stringValue } diff --git a/Source/Bindings.swift b/Source/Bindings.swift new file mode 100644 index 0000000..817cb5b --- /dev/null +++ b/Source/Bindings.swift @@ -0,0 +1,16 @@ +public protocol BindingsProtocol { + associatedtype Owner: AnyObject + + var owner: Owner { get } +} + +public protocol BindablesProviding: class {} +extension BindablesProviding { + public var bindables: Bindables { + return Bindables(owner: self) + } +} + +public struct Bindables: BindingsProtocol { + public let owner: Owner +} diff --git a/Source/Foundation/Association.swift b/Source/Foundation/Association.swift index 976b6c9..8be4d03 100644 --- a/Source/Foundation/Association.swift +++ b/Source/Foundation/Association.swift @@ -15,13 +15,12 @@ import ReactiveCocoa /// /// This can be used as an alternative to `DynamicProperty` for creating strongly typed /// bindings on Cocoa objects. -@warn_unused_result(message="Did you forget to use the property?") -public func associatedProperty(host: AnyObject, keyPath: StaticString) -> MutableProperty { - let initial: AnyObject -> String = { host in - host.valueForKeyPath(keyPath.stringValue) as? String ?? "" +public func associatedProperty(_ host: AnyObject, keyPath: StaticString) -> MutableProperty { + let initial: (AnyObject) -> String = { host in + host.value(forKeyPath: String(keyPath)) as? String ?? "" } let setter: (AnyObject, String) -> () = { host, newValue in - host.setValue(newValue, forKeyPath: keyPath.stringValue) + host.setValue(newValue, forKeyPath: String(keyPath)) } return associatedProperty(host, key: keyPath.utf8Start, initial: initial, setter: setter) } @@ -33,13 +32,12 @@ public func associatedProperty(host: AnyObject, keyPath: StaticString) -> Mutabl /// /// This can be used as an alternative to `DynamicProperty` for creating strongly typed /// bindings on Cocoa objects. -@warn_unused_result(message="Did you forget to use the property?") -public func associatedProperty(host: AnyObject, keyPath: StaticString, @noescape placeholder: () -> T) -> MutableProperty { +public func associatedProperty(_ host: AnyObject, keyPath: StaticString, placeholder: @noescape () -> T) -> MutableProperty { let setter: (AnyObject, T) -> () = { host, newValue in - host.setValue(newValue, forKeyPath: keyPath.stringValue) + host.setValue(newValue, forKeyPath: String(keyPath)) } return associatedProperty(host, key: keyPath.utf8Start, initial: { host in - host.valueForKeyPath(keyPath.stringValue) as? T ?? placeholder() + host.value(forKeyPath: String(keyPath)) as? T ?? placeholder() }, setter: setter) } @@ -49,8 +47,7 @@ public func associatedProperty(host: AnyObject, keyPath: StaticStr /// /// This can be used as an alternative to `DynamicProperty` for creating strongly typed /// bindings on Cocoa objects. -@warn_unused_result(message="Did you forget to use the property?") -public func associatedProperty(host: Host, key: UnsafePointer<()>, @noescape initial: Host -> T, setter: (Host, T) -> (), @noescape setUp: MutableProperty -> () = { _ in }) -> MutableProperty { +public func associatedProperty(_ host: Host, key: UnsafePointer<()>, initial: @noescape (Host) -> T, setter: (Host, T) -> (), setUp: @noescape (MutableProperty) -> () = { _ in }) -> MutableProperty { return associatedObject(host, key: key) { host in let property = MutableProperty(initial(host)) @@ -69,7 +66,7 @@ public func associatedProperty(host: Host, key: UnsafePointe /// On first use attaches the object returned from `initial` to the `host` object using /// `key` via `objc_setAssociatedObject`. On subsequent usage, returns said object via /// `objc_getAssociatedObject`. -public func associatedObject(host: Host, key: UnsafePointer<()>, @noescape initial: Host -> T) -> T { +public func associatedObject(_ host: Host, key: UnsafePointer<()>, initial: @noescape (Host) -> T) -> T { var value = objc_getAssociatedObject(host, key) as? T if value == nil { value = initial(host) diff --git a/Source/Foundation/Data.swift b/Source/Foundation/Data.swift new file mode 100644 index 0000000..53aff66 --- /dev/null +++ b/Source/Foundation/Data.swift @@ -0,0 +1,39 @@ +// +// Data.swift +// Rex +// +// Created by Ilya Laryionau on 10/05/15. +// Copyright (c) 2015 Neil Pankey. All rights reserved. +// + +import ReactiveCocoa + +extension Data { + /// Read the data at the URL, sending the result or an error. + public static func rex_data(contentsOf url: URL, options: Data.ReadingOptions = []) -> SignalProducer { + return SignalProducer { observer, disposable in + do { + let data = try Data(contentsOf: url, options: options) + observer.sendNext(data) + observer.sendCompleted() + } catch { + observer.sendFailed(error as NSError) + } + } + } +} + +extension NSData { + /// Read the data at the URL, sending the result or an error. + public static func rex_data(contentsOf url: URL, options: NSData.ReadingOptions = []) -> SignalProducer { + return SignalProducer { observer, disposable in + do { + let data = try NSData(contentsOf: url, options: options) + observer.sendNext(data) + observer.sendCompleted() + } catch { + observer.sendFailed(error as NSError) + } + } + } +} diff --git a/Source/Foundation/NSObject.swift b/Source/Foundation/NSObject.swift index c839ef1..531085f 100644 --- a/Source/Foundation/NSObject.swift +++ b/Source/Foundation/NSObject.swift @@ -15,16 +15,15 @@ extension NSObject { /// /// Swift classes deriving `NSObject` must declare properties as `dynamic` for /// them to work with KVO. However, this is not recommended practice. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func rex_producerForKeyPath(keyPath: String) -> SignalProducer { - return self.rac_valuesForKeyPath(keyPath, observer: nil) + public func rex_producer(forKeyPath keyPath: String) -> SignalProducer { + return self.rac_values(forKeyPath: keyPath, observer: nil) .toSignalProducer() .map { $0 as! T } .flatMapError { error in // Errors aren't possible, but the compiler doesn't know that. assertionFailure("Unexpected error from KVO signal: \(error)") return .empty - } + } } /// Creates a signal that will be triggered when the object diff --git a/Source/Foundation/NSUserDefaults.swift b/Source/Foundation/UserDefaults.swift similarity index 69% rename from Source/Foundation/NSUserDefaults.swift rename to Source/Foundation/UserDefaults.swift index 702dd93..c0a9e0b 100644 --- a/Source/Foundation/NSUserDefaults.swift +++ b/Source/Foundation/UserDefaults.swift @@ -9,21 +9,20 @@ import ReactiveCocoa import enum Result.NoError -extension NSUserDefaults { +extension UserDefaults { /// Sends value of `key` whenever it changes. Attempts to filter out repeats /// by casting to NSObject and checking for equality. If the values aren't /// convertible this will generate events whenever _any_ value in NSUserDefaults /// changes. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func rex_valueForKey(key: String) -> SignalProducer { - let center = NSNotificationCenter.defaultCenter() - let initial = objectForKey(key) + public func rex_value(forKey key: String) -> SignalProducer { + let center = NotificationCenter.default + let initial = object(forKey: key) - let changes = center.rac_notifications(NSUserDefaultsDidChangeNotification) + let changes = center.rac_notifications(forName: UserDefaults.didChangeNotification) .map { _ in // The notification doesn't provide what changed so we have to look // it up every time - self.objectForKey(key) + self.object(forKey: key) } return SignalProducer(value: initial) diff --git a/Source/Property.swift b/Source/Property.swift index 230d0ab..c743c4e 100644 --- a/Source/Property.swift +++ b/Source/Property.swift @@ -9,40 +9,35 @@ import ReactiveCocoa import enum Result.NoError -extension PropertyType where Value == Bool { +extension PropertyProtocol where Value == Bool { /// The conjunction of `self` and `other`. - @warn_unused_result(message="Did you forget to use the property?") - public func and(other: P) -> AndProperty { + public func and(_ other: P) -> AndProperty { return AndProperty(terms: [AnyProperty(self), AnyProperty(other)]) } /// The conjunction of `self` and `other`. - @warn_unused_result(message="Did you forget to use the property?") - public func and(other: AnyProperty) -> AndProperty { + public func and(_ other: AnyProperty) -> AndProperty { return AndProperty(terms: [AnyProperty(self), other]) } /// The disjunction of `self` and `other`. - @warn_unused_result(message="Did you forget to use the property?") - public func or(other: P) -> OrProperty { + public func or(_ other: P) -> OrProperty { return OrProperty(terms: [AnyProperty(self), AnyProperty(other)]) } /// The disjunction of `self` and `other`. - @warn_unused_result(message="Did you forget to use the property?") - public func or(other: AnyProperty) -> OrProperty { + public func or(_ other: AnyProperty) -> OrProperty { return OrProperty(terms: [AnyProperty(self), other]) } /// A negated property of `self`. - @warn_unused_result(message="Did you forget to use the property?") public func not() -> NotProperty { return NotProperty(source: AnyProperty(self), invert: true) } } /// Specialized `PropertyType` for the conjuction of a set of boolean properties. -public struct AndProperty: PropertyType { +public struct AndProperty: PropertyProtocol { public let terms: [AnyProperty] public var value: Bool { @@ -51,27 +46,25 @@ public struct AndProperty: PropertyType { public var producer: SignalProducer { let producers = terms.map { $0.producer } - return combineLatest(producers).map { values in + return SignalProducer.combineLatest(producers).map { values in return values.reduce(true) { $0 && $1 } } } public var signal: Signal { let signals = terms.map { $0.signal } - return combineLatest(signals).map { values in + return Signal.combineLatest(signals).map { values in return values.reduce(true) { $0 && $1 } } } /// Creates a new property with an additional conjunctive term. - @warn_unused_result(message="Did you forget to use the property?") - public func and

(other: P) -> AndProperty { + public func and

(_ other: P) -> AndProperty { return AndProperty(terms: terms + [AnyProperty(other)]) } /// Creates a new property with an additional conjunctive term. - @warn_unused_result(message="Did you forget to use the property?") - public func and(other: AnyProperty) -> AndProperty { + public func and(_ other: AnyProperty) -> AndProperty { return AndProperty(terms: terms + [other]) } @@ -81,7 +74,7 @@ public struct AndProperty: PropertyType { } /// Specialized `PropertyType` for the disjunction of a set of boolean properties. -public struct OrProperty: PropertyType { +public struct OrProperty: PropertyProtocol { public let terms: [AnyProperty] public var value: Bool { @@ -90,27 +83,25 @@ public struct OrProperty: PropertyType { public var producer: SignalProducer { let producers = terms.map { $0.producer } - return combineLatest(producers).map { values in + return SignalProducer.combineLatest(producers).map { values in return values.reduce(false) { $0 || $1 } } } public var signal: Signal { let signals = terms.map { $0.signal } - return combineLatest(signals).map { values in + return Signal.combineLatest(signals).map { values in return values.reduce(false) { $0 || $1 } } } /// Creates a new property with an additional disjunctive term. - @warn_unused_result(message="Did you forget to use the property?") - public func or

(other: P) -> OrProperty { + public func or

(_ other: P) -> OrProperty { return OrProperty(terms: terms + [AnyProperty(other)]) } /// Creates a new property with an additional disjunctive term. - @warn_unused_result(message="Did you forget to use the property?") - public func or(other: AnyProperty) -> OrProperty { + public func or(_ other: AnyProperty) -> OrProperty { return OrProperty(terms: terms + [other]) } @@ -120,7 +111,7 @@ public struct OrProperty: PropertyType { } /// Specialized `PropertyType` for the negation of a boolean property. -public struct NotProperty: PropertyType { +public struct NotProperty: PropertyProtocol { private let source: AnyProperty private let invert: Bool @@ -137,7 +128,6 @@ public struct NotProperty: PropertyType { } /// A negated property of `self`. - @warn_unused_result(message="Did you forget to use the property?") public func not() -> NotProperty { return NotProperty(source: source, invert: !invert) } diff --git a/Source/RACSignal.swift b/Source/RACSignal.swift index 8d01fa5..f961cc5 100644 --- a/Source/RACSignal.swift +++ b/Source/RACSignal.swift @@ -17,7 +17,6 @@ extension RACSignal { /// for certain things, like event streams (see `UIControl.signalForControlEvents`) /// use this method to be able to expose these inherently hot streams /// as `Signal`s. - @warn_unused_result(message="Did you forget to call `observe` on the signal?") public func rex_toSignal() -> Signal { return Signal { observer in return self.toSignalProducer().start(observer) @@ -27,7 +26,6 @@ extension RACSignal { /// Converts `self` into a `Signal`, that can be used /// with the `takeUntil` operator, or as an "activation" signal. /// (e.g. a button) - @warn_unused_result(message="Did you forget to call `observe` on the signal?") public final func rex_toTriggerSignal() -> Signal<(), NoError> { return self .rex_toSignal() diff --git a/Source/Signal.swift b/Source/Signal.swift index 4bc4837..723d80e 100644 --- a/Source/Signal.swift +++ b/Source/Signal.swift @@ -9,24 +9,23 @@ import ReactiveCocoa import enum Result.NoError -extension SignalType { +extension SignalProtocol { /// Applies `transform` to values from `signal` with non-`nil` results unwrapped and /// forwared on the returned signal. - @warn_unused_result(message="Did you forget to call `observe` on the signal?") - public func filterMap(transform: Value -> U?) -> Signal { + public func filterMap(_ transform: (Value) -> U?) -> Signal { return Signal { observer in return self.observe { event in switch event { - case let .Next(value): + case let .next(value): if let mapped = transform(value) { observer.sendNext(mapped) } - case let .Failed(error): + case let .failed(error): observer.sendFailed(error) - case .Completed: + case .completed: observer.sendCompleted() - case .Interrupted: + case .interrupted: observer.sendInterrupted() } } @@ -35,20 +34,19 @@ extension SignalType { /// Returns a signal that drops `Error` sending `replacement` terminal event /// instead, defaulting to `Completed`. - @warn_unused_result(message="Did you forget to call `observe` on the signal?") - public func ignoreError(replacement replacement: Event = .Completed) -> Signal { + public func ignoreError(replacement: Event = .completed) -> Signal { precondition(replacement.isTerminating) return Signal { observer in return self.observe { event in switch event { - case let .Next(value): + case let .next(value): observer.sendNext(value) - case .Failed: + case .failed: observer.action(replacement) - case .Completed: + case .completed: observer.sendCompleted() - case .Interrupted: + case .interrupted: observer.sendInterrupted() } } @@ -60,16 +58,15 @@ extension SignalType { /// /// If the interval is 0, the timeout will be scheduled immediately. The signal /// must complete synchronously (or on a faster scheduler) to avoid the timeout. - @warn_unused_result(message="Did you forget to call `observe` on the signal?") - public func timeoutAfter(interval: NSTimeInterval, withEvent event: Event, onScheduler scheduler: DateSchedulerType) -> Signal { + public func timeout(after interval: TimeInterval, with event: Event, on scheduler: DateSchedulerProtocol) -> Signal { precondition(interval >= 0) precondition(event.isTerminating) return Signal { observer in let disposable = CompositeDisposable() - let date = scheduler.currentDate.dateByAddingTimeInterval(interval) - disposable += scheduler.scheduleAfter(date) { + let date = scheduler.currentDate.addingTimeInterval(interval) + disposable += scheduler.schedule(after: date) { observer.action(event) } @@ -85,16 +82,15 @@ extension SignalType { /// /// This operator could be used to coalesce multiple notifications in a short time /// frame by only showing the first one. - @warn_unused_result(message="Did you forget to call `observe` on the signal?") - public func muteFor(interval: NSTimeInterval, clock: DateSchedulerType) -> Signal { + public func mute(for interval: TimeInterval, clock: DateSchedulerProtocol) -> Signal { precondition(interval > 0) var expires = clock.currentDate return filter { _ in let now = clock.currentDate - if expires.compare(now) != .OrderedDescending { - expires = now.dateByAddingTimeInterval(interval) + if expires.compare(now) != .orderedDescending { + expires = now.addingTimeInterval(interval) return true } return false @@ -102,20 +98,19 @@ extension SignalType { } } -extension SignalType where Value: SequenceType { +extension SignalProtocol where Value: Sequence { /// Returns a signal that flattens sequences of elements. The inverse of `collect`. - @warn_unused_result(message="Did you forget to call `observe` on the signal?") - public func uncollect() -> Signal { - return Signal { observer in + public func uncollect() -> Signal { + return Signal { observer in return self.observe { event in switch event { - case let .Next(sequence): + case let .next(sequence): sequence.forEach { observer.sendNext($0) } - case let .Failed(error): + case let .failed(error): observer.sendFailed(error) - case .Completed: + case .completed: observer.sendCompleted() - case .Interrupted: + case .interrupted: observer.sendInterrupted() } } diff --git a/Source/SignalProducer.swift b/Source/SignalProducer.swift index c977428..69dbd79 100644 --- a/Source/SignalProducer.swift +++ b/Source/SignalProducer.swift @@ -9,28 +9,27 @@ import ReactiveCocoa import enum Result.NoError -extension SignalProducerType { +extension SignalProducerProtocol { /// Buckets each received value into a group based on the key returned /// from `grouping`. Termination events on the original signal are /// also forwarded to each producer group. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func groupBy(grouping: Value -> Key) -> SignalProducer<(Key, SignalProducer), Error> { + public func group(by grouping: (Value) -> Key) -> SignalProducer<(Key, SignalProducer), Error> { return SignalProducer<(Key, SignalProducer), Error> { observer, disposable in var groups: [Key: Signal.Observer] = [:] - let lock = NSRecursiveLock() + let lock = RecursiveLock() lock.name = "me.neilpa.rex.groupBy" self.start { event in switch event { - case let .Next(value): + case let .next(value): let key = grouping(value) lock.lock() var group = groups[key] if group == nil { - let (producer, innerObserver) = SignalProducer.buffer(Int.max) + let (producer, innerObserver) = SignalProducer.bufferingProducer(upTo: Int.max) observer.sendNext(key, producer) groups[key] = innerObserver @@ -40,15 +39,15 @@ extension SignalProducerType { group!.sendNext(value) - case let .Failed(error): + case let .failed(error): observer.sendFailed(error) groups.values.forEach { $0.sendFailed(error) } - case .Completed: + case .completed: observer.sendCompleted() groups.values.forEach { $0.sendCompleted() } - case .Interrupted: + case .interrupted: observer.sendInterrupted() groups.values.forEach { $0.sendInterrupted() } } @@ -58,15 +57,13 @@ extension SignalProducerType { /// Applies `transform` to values from self with non-`nil` results unwrapped and /// forwared on the returned producer. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func filterMap(transform: Value -> U?) -> SignalProducer { + public func filterMap(_ transform: (Value) -> U?) -> SignalProducer { return lift { $0.filterMap(transform) } } /// Returns a producer that drops `Error` sending `replacement` terminal event /// instead, defaulting to `Completed`. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func ignoreError(replacement replacement: Event = .Completed) -> SignalProducer { + public func ignoreError(replacement: Event = .completed) -> SignalProducer { precondition(replacement.isTerminating) return lift { $0.ignoreError(replacement: replacement) } } @@ -76,9 +73,8 @@ extension SignalProducerType { /// /// If the interval is 0, the timeout will be scheduled immediately. The producer /// must complete synchronously (or on a faster scheduler) to avoid the timeout. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func timeoutAfter(interval: NSTimeInterval, withEvent event: Event, onScheduler scheduler: DateSchedulerType) -> SignalProducer { - return lift { $0.timeoutAfter(interval, withEvent: event, onScheduler: scheduler) } + public func timeout(after interval: TimeInterval, with event: Event, on scheduler: DateSchedulerProtocol) -> SignalProducer { + return lift { $0.timeout(after: interval, with: event, on: scheduler) } } /// Forwards a value and then mutes the producer by dropping all subsequent values @@ -88,22 +84,19 @@ extension SignalProducerType { /// /// This operator could be used to coalesce multiple notifications in a short time /// frame by only showing the first one. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func muteFor(interval: NSTimeInterval, clock: DateSchedulerType) -> SignalProducer { - return lift { $0.muteFor(interval, clock: clock) } + public func mute(for interval: TimeInterval, clock: DateSchedulerProtocol) -> SignalProducer { + return lift { $0.mute(for: interval, clock: clock) } } /// Delays the start of the producer by `interval` on the provided scheduler. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func deferred(interval: NSTimeInterval, onScheduler scheduler: DateSchedulerType) -> SignalProducer { + public func `defer`(by interval: TimeInterval, on scheduler: DateSchedulerProtocol) -> SignalProducer { return SignalProducer.empty - .delay(interval, onScheduler: scheduler) + .delay(interval, on: scheduler) .concat(self.producer) } /// Delays retrying on failure by `interval` up to `count` attempts. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func deferredRetry(interval: NSTimeInterval, onScheduler scheduler: DateSchedulerType, count: Int = .max) -> SignalProducer { + public func deferredRetry(interval: TimeInterval, on scheduler: DateSchedulerProtocol, count: Int = .max) -> SignalProducer { precondition(count >= 0) if count == 0 { @@ -115,20 +108,143 @@ extension SignalProducerType { // The final attempt shouldn't defer the error if it fails var producer = SignalProducer(error: error) if retries > 0 { - producer = producer.deferred(interval, onScheduler: scheduler) + producer = producer.defer(by: interval, on: scheduler) } retries -= 1 return producer } - .retry(count) + .retry(upTo: count) } } -extension SignalProducerType where Value: SequenceType { +extension SignalProducerProtocol where Value: Sequence { /// Returns a producer that flattens sequences of elements. The inverse of `collect`. - @warn_unused_result(message="Did you forget to call `start` on the producer?") - public func uncollect() -> SignalProducer { + public func uncollect() -> SignalProducer { return lift { $0.uncollect() } } } + +/// Temporary replacement of `buffer(upTo:)`. +/// https://github.com/ReactiveCocoa/ReactiveCocoa/blob/RAC5-swift3/ReactiveCocoa/Swift/SignalProducer.swift + +extension SignalProducer { + private static func bufferingProducer(upTo capacity: Int) -> (SignalProducer, Signal.Observer) { + precondition(capacity >= 0, "Invalid capacity: \(capacity)") + + // Used as an atomic variable so we can remove observers without needing + // to run on a serial queue. + let state: Atomic> = Atomic(BufferState()) + + let producer = self.init { observer, disposable in + // Assigned to when replay() is invoked synchronously below. + var token: RemovalToken? + + let replayBuffer = ReplayBuffer() + var replayValues: [Value] = [] + var replayToken: RemovalToken? + var next = state.modify { state in + replayValues = state.values + if replayValues.isEmpty { + token = state.observers?.insert(observer) + } else { + replayToken = state.replayBuffers.insert(replayBuffer) + } + } + + while !replayValues.isEmpty { + replayValues.forEach(observer.sendNext) + + next = state.modify { state in + replayValues = replayBuffer.values + replayBuffer.values = [] + if replayValues.isEmpty { + if let replayToken = replayToken { + state.replayBuffers.remove(using: replayToken) + } + token = state.observers?.insert(observer) + } + } + } + + if let terminationEvent = next.terminationEvent { + observer.action(terminationEvent) + } + + if let token = token { + disposable += { + state.modify { state in + state.observers?.remove(using: token) + } + } + } + } + + let bufferingObserver: Signal.Observer = Observer { event in + let originalState = state.modify { state in + if let value = event.value { + state.add(value, upTo: capacity) + } else { + // Disconnect all observers and prevent future + // attachments. + state.terminationEvent = event + state.observers = nil + } + } + + originalState.observers?.forEach { $0.action(event) } + } + + return (producer, bufferingObserver) + } +} + +/// A uniquely identifying token for Observers that are replaying values in +/// BufferState. +private final class ReplayBuffer { + private var values: [Value] = [] +} + +private struct BufferState { + /// All values in the buffer. + var values: [Value] = [] + + /// Any terminating event sent to the buffer. + /// + /// This will be nil if termination has not occurred. + var terminationEvent: Event? + + /// The observers currently attached to the buffered producer, or nil if the + /// producer was terminated. + var observers: Bag.Observer>? = Bag() + + /// The set of unused replay token identifiers. + var replayBuffers: Bag> = Bag() + + /// Appends a new value to the buffer, trimming it down to the given capacity + /// if necessary. + mutating func add(_ value: Value, upTo capacity: Int) { + precondition(capacity >= 0) + + for buffer in replayBuffers { + buffer.values.append(value) + } + + if capacity == 0 { + values = [] + return + } + + if capacity == 1 { + values = [ value ] + return + } + + values.append(value) + + let overflow = values.count - capacity + if overflow > 0 { + values.removeSubrange(0.. { - return associatedProperty(self, key: &enabledKey, initial: { $0.enabled }, setter: { $0.enabled = $1 }) + return associatedProperty(self, key: &enabledKey, initial: { $0.isEnabled }, setter: { $0.isEnabled = $1 }) } } diff --git a/Source/UIKit/UIButton.swift b/Source/UIKit/UIButton.swift index ea49aef..81bda04 100644 --- a/Source/UIKit/UIButton.swift +++ b/Source/UIKit/UIButton.swift @@ -20,13 +20,13 @@ extension UIButton { let property = MutableProperty(initial) property.producer - .combinePrevious(initial) + .combinePrevious(initial: initial) .startWithNext { [weak host] previous, next in - host?.removeTarget(previous, action: CocoaAction.selector, forControlEvents: .TouchUpInside) - host?.addTarget(next, action: CocoaAction.selector, forControlEvents: .TouchUpInside) + host?.removeTarget(previous, action: CocoaAction.selector, for: .touchUpInside) + host?.addTarget(next, action: CocoaAction.selector, for: .touchUpInside) } - host.rex_enabled <~ property.producer.flatMap(.Latest) { $0.rex_enabledProducer } + host.rex_enabled <~ property.producer.flatMap(.latest) { $0.rex_enabledProducer } return property } @@ -35,7 +35,7 @@ extension UIButton { /// Wraps a button's `title` text in a bindable property. Note that this only applies /// to `UIControlState.Normal`. public var rex_title: MutableProperty { - return associatedProperty(self, key: &titleKey, initial: { $0.titleForState(.Normal) ?? "" }, setter: { $0.setTitle($1, forState: .Normal) }) + return associatedProperty(self, key: &titleKey, initial: { $0.title(for: .normal) ?? "" }, setter: { $0.setTitle($1, for: .normal) }) } } diff --git a/Source/UIKit/UIControl.swift b/Source/UIKit/UIControl.swift index 1ad6e9a..49c1d6b 100644 --- a/Source/UIKit/UIControl.swift +++ b/Source/UIKit/UIControl.swift @@ -14,9 +14,8 @@ extension UIControl { #if os(iOS) /// Creates a producer for the sender whenever a specified control event is triggered. - @warn_unused_result(message="Did you forget to use the property?") - public func rex_controlEvents(events: UIControlEvents) -> SignalProducer { - return rac_signalForControlEvents(events) + public func rex_controlEvents(_ events: UIControlEvents) -> SignalProducer { + return rac_signal(for: events) .toSignalProducer() .map { $0 as? UIControl } .flatMapError { _ in SignalProducer(value: nil) } @@ -27,11 +26,10 @@ extension UIControl { /// This property uses `UIControlEvents.ValueChanged` and `UIControlEvents.EditingChanged` /// events to detect changes and keep the value up-to-date. // - @warn_unused_result(message="Did you forget to use the property?") - class func rex_value(host: Host, getter: Host -> T, setter: (Host, T) -> ()) -> MutableProperty { + class func rex_value(_ host: Host, getter: (Host) -> T, setter: (Host, T) -> ()) -> MutableProperty { return associatedProperty(host, key: &valueChangedKey, initial: getter, setter: setter) { property in property <~ - host.rex_controlEvents([.ValueChanged, .EditingChanged]) + host.rex_controlEvents([.valueChanged, .editingChanged]) .filterMap { $0 as? Host } .filterMap(getter) } @@ -40,17 +38,17 @@ extension UIControl { /// Wraps a control's `enabled` state in a bindable property. public var rex_enabled: MutableProperty { - return associatedProperty(self, key: &enabledKey, initial: { $0.enabled }, setter: { $0.enabled = $1 }) + return associatedProperty(self, key: &enabledKey, initial: { $0.isEnabled }, setter: { $0.isEnabled = $1 }) } /// Wraps a control's `selected` state in a bindable property. public var rex_selected: MutableProperty { - return associatedProperty(self, key: &selectedKey, initial: { $0.selected }, setter: { $0.selected = $1 }) + return associatedProperty(self, key: &selectedKey, initial: { $0.isSelected }, setter: { $0.isSelected = $1 }) } /// Wraps a control's `highlighted` state in a bindable property. public var rex_highlighted: MutableProperty { - return associatedProperty(self, key: &highlightedKey, initial: { $0.highlighted }, setter: { $0.highlighted = $1 }) + return associatedProperty(self, key: &highlightedKey, initial: { $0.isHighlighted }, setter: { $0.isHighlighted = $1 }) } } diff --git a/Source/UIKit/UIDatePicker.swift b/Source/UIKit/UIDatePicker.swift index 75f0d38..3fbbd32 100644 --- a/Source/UIKit/UIDatePicker.swift +++ b/Source/UIKit/UIDatePicker.swift @@ -12,7 +12,7 @@ import UIKit extension UIDatePicker { // Wraps a datePicker's `date` value in a bindable property. - public var rex_date: MutableProperty { + public var rex_date: MutableProperty { return UIControl.rex_value(self, getter: { $0.date }, setter: { $0.date = $1 }) } } diff --git a/Source/UIKit/UILabel.swift b/Source/UIKit/UILabel.swift index c47746f..0078d7c 100644 --- a/Source/UIKit/UILabel.swift +++ b/Source/UIKit/UILabel.swift @@ -16,7 +16,7 @@ extension UILabel { } /// Wraps a label's `attributedText` value in a bindable property. - public var rex_attributedText: MutableProperty { + public var rex_attributedText: MutableProperty { return associatedProperty(self, key: &attributedTextKey, initial: { $0.attributedText }, setter: { $0.attributedText = $1 }) } diff --git a/Source/UIKit/UISegmentedControl.swift b/Source/UIKit/UISegmentedControl.swift index 465c76e..acd990a 100644 --- a/Source/UIKit/UISegmentedControl.swift +++ b/Source/UIKit/UISegmentedControl.swift @@ -13,7 +13,7 @@ extension UISegmentedControl { /// Wraps a segmentedControls `selectedSegmentIndex` state in a bindable property. public var rex_selectedSegmentIndex: MutableProperty { let property = associatedProperty(self, key: &selectedSegmentIndexKey, initial: { $0.selectedSegmentIndex }, setter: { $0.selectedSegmentIndex = $1 }) - property <~ rex_controlEvents(.ValueChanged) + property <~ rex_controlEvents(.valueChanged) .filterMap { ($0 as? UISegmentedControl)?.selectedSegmentIndex } return property } diff --git a/Source/UIKit/UISwitch.swift b/Source/UIKit/UISwitch.swift index e02c890..e1b6612 100644 --- a/Source/UIKit/UISwitch.swift +++ b/Source/UIKit/UISwitch.swift @@ -13,6 +13,6 @@ extension UISwitch { /// Wraps a switch's `on` value in a bindable property. public var rex_on: MutableProperty { - return UIControl.rex_value(self, getter: { $0.on }, setter: { $0.on = $1 }) + return UIControl.rex_value(self, getter: { $0.isOn }, setter: { $0.isOn = $1 }) } } diff --git a/Source/UIKit/UITextField.swift b/Source/UIKit/UITextField.swift index c9fa38c..5b6d849 100644 --- a/Source/UIKit/UITextField.swift +++ b/Source/UIKit/UITextField.swift @@ -13,7 +13,7 @@ extension UITextField { /// Wraps a textField's `text` value in a bindable property. public var rex_text: MutableProperty { - let getter: UITextField -> String? = { $0.text } + let getter: (UITextField) -> String? = { $0.text } let setter: (UITextField, String?) -> () = { $0.text = $1 } #if os(iOS) return UIControl.rex_value(self, getter: getter, setter: setter) diff --git a/Source/UIKit/UITextView.swift b/Source/UIKit/UITextView.swift index 95a9b19..c78df6d 100644 --- a/Source/UIKit/UITextView.swift +++ b/Source/UIKit/UITextView.swift @@ -14,8 +14,8 @@ extension UITextView { /// Sends the textView's string value whenever it changes. public var rex_text: SignalProducer { - return NSNotificationCenter.defaultCenter() - .rac_notifications(UITextViewTextDidChangeNotification, object: self) + return NotificationCenter.default + .rac_notifications(forName: .UITextViewTextDidChange, object: self) .filterMap { ($0.object as? UITextView)?.text } } } diff --git a/Source/UIKit/UIView.swift b/Source/UIKit/UIView.swift index f0a67f7..541faa7 100644 --- a/Source/UIKit/UIView.swift +++ b/Source/UIKit/UIView.swift @@ -9,21 +9,32 @@ import ReactiveCocoa import UIKit -extension UIView { +extension UIView: BindablesProviding {} + +extension BindingsProtocol where Owner: UIView { /// Wraps a view's `alpha` value in a bindable property. - public var rex_alpha: MutableProperty { - return associatedProperty(self, key: &alphaKey, initial: { $0.alpha }, setter: { $0.alpha = $1 }) + public var alpha: MutableProperty { + return associatedProperty(owner, + key: &alphaKey, + initial: { $0.alpha }, + setter: { $0.alpha = $1 }) } - /// Wraps a view's `hidden` state in a bindable property. - public var rex_hidden: MutableProperty { - return associatedProperty(self, key: &hiddenKey, initial: { $0.hidden }, setter: { $0.hidden = $1 }) + /// Wraps a view's `isHidden` state in a bindable property. + public var isHidden: MutableProperty { + return associatedProperty(owner, + key: &hiddenKey, + initial: { $0.isHidden }, + setter: { $0.isHidden = $1 }) } - - /// Wraps a view's `userInteractionEnabled` state in a bindable property. - public var rex_userInteractionEnabled: MutableProperty { - return associatedProperty(self, key: &userInteractionEnabledKey, initial: { $0.userInteractionEnabled }, setter: { $0.userInteractionEnabled = $1 }) + + /// Wraps a view's `isUserInteractionEnabled` state in a bindable property. + public var isUserInteractionEnabled: MutableProperty { + return associatedProperty(owner, + key: &userInteractionEnabledKey, + initial: { $0.isUserInteractionEnabled }, + setter: { $0.isUserInteractionEnabled = $1 }) } } diff --git a/Source/UIKit/UIViewController.swift b/Source/UIKit/UIViewController.swift index f16264b..ca3aa48 100644 --- a/Source/UIKit/UIViewController.swift +++ b/Source/UIKit/UIViewController.swift @@ -14,36 +14,36 @@ extension UIViewController { /// Returns a `Signal`, that will be triggered /// when `self`'s `viewDidDisappear` is called public var rex_viewDidDisappear: Signal<(), NoError> { - return triggerForSelector(#selector(UIViewController.viewDidDisappear(_:))) + return trigger(for: #selector(UIViewController.viewDidDisappear(_:))) } - + /// Returns a `Signal`, that will be triggered /// when `self`'s `viewWillDisappear` is called public var rex_viewWillDisappear: Signal<(), NoError> { - return triggerForSelector(#selector(UIViewController.viewWillDisappear(_:))) + return trigger(for: #selector(UIViewController.viewWillDisappear(_:))) } - + /// Returns a `Signal`, that will be triggered /// when `self`'s `viewDidAppear` is called public var rex_viewDidAppear: Signal<(), NoError> { - return triggerForSelector(#selector(UIViewController.viewDidAppear(_:))) + return trigger(for: #selector(UIViewController.viewDidAppear(_:))) } - + /// Returns a `Signal`, that will be triggered /// when `self`'s `viewWillAppear` is called public var rex_viewWillAppear: Signal<(), NoError> { - return triggerForSelector(#selector(UIViewController.viewWillAppear(_:))) + return trigger(for: #selector(UIViewController.viewWillAppear(_:))) } - - private func triggerForSelector(selector: Selector) -> Signal<(), NoError> { + + private func trigger(for selector: Selector) -> Signal<(), NoError> { return self - .rac_signalForSelector(selector) + .rac_signal(for: selector) .rex_toTriggerSignal() } - - public typealias DismissingCompletion = (Void -> Void)? + + public typealias DismissingCompletion = ((Void) -> Void)? public typealias DismissingInformation = (animated: Bool, completion: DismissingCompletion)? - + /// Wraps a viewController's `dismissViewControllerAnimated` function in a bindable property. /// It mimics the same input as `dismissViewControllerAnimated`: a `Bool` flag for the animation /// and a `(Void -> Void)?` closure for `completion`. @@ -55,21 +55,21 @@ extension UIViewController { /// The dismissal observation can be made either with binding (example above) /// or `viewController.dismissViewControllerAnimated(true, completion: nil)` public var rex_dismissAnimated: MutableProperty { - - let initial: UIViewController -> DismissingInformation = { _ in nil } + + let initial: (UIViewController) -> DismissingInformation = { _ in nil } let setter: (UIViewController, DismissingInformation) -> Void = { host, dismissingInfo in - + guard let unwrapped = dismissingInfo else { return } - host.dismissViewControllerAnimated(unwrapped.animated, completion: unwrapped.completion) + host.dismiss(animated: unwrapped.animated, completion: unwrapped.completion) } - + let property = associatedProperty(self, key: &dismissModally, initial: initial, setter: setter) { property in - property <~ self.rac_signalForSelector(#selector(UIViewController.dismissViewControllerAnimated(_:completion:))) - .takeUntilBlock { _ in property.value != nil } + property <~ self.rac_signal(for: #selector(UIViewController.dismiss)) + .take { _ in property.value != nil } .rex_toTriggerSignal() .map { _ in return nil } } - + return property } } diff --git a/Tests/ActionTests.swift b/Tests/ActionTests.swift index abd4d1c..b6d7338 100644 --- a/Tests/ActionTests.swift +++ b/Tests/ActionTests.swift @@ -13,8 +13,8 @@ import enum Result.NoError final class ActionTests: XCTestCase { - enum TestError: ErrorType { - case Unknown + enum TestError: ErrorProtocol { + case unknown } func testStarted() { @@ -33,7 +33,9 @@ final class ActionTests: XCTestCase { } func testCompleted() { - let (producer, observer) = SignalProducer.buffer(Int.max) + let (signal, observer) = Signal.pipe() + let producer = SignalProducer(signal: signal) + let action = Action { producer } var completed = false @@ -53,7 +55,9 @@ final class ActionTests: XCTestCase { } func testCompletedOnFailed() { - let (producer, observer) = SignalProducer.buffer(Int.max) + let (signal, observer) = Signal.pipe() + let producer = SignalProducer(signal: signal) + let action = Action { producer } var completed = false @@ -65,7 +69,7 @@ final class ActionTests: XCTestCase { .apply() .start() - observer.sendFailed(.Unknown) + observer.sendFailed(.unknown) XCTAssertFalse(completed) } } diff --git a/Tests/Foundation/NSObjectTests.swift b/Tests/Foundation/NSObjectTests.swift index 5ffc070..83cee3a 100644 --- a/Tests/Foundation/NSObjectTests.swift +++ b/Tests/Foundation/NSObjectTests.swift @@ -16,7 +16,7 @@ final class NSObjectTests: XCTestCase { let object = Object() var value: String = "" - object.rex_producerForKeyPath("string").startWithNext { value = $0 } + object.rex_producer(forKeyPath: "string").startWithNext { value = $0 } XCTAssertEqual(value, "foo") object.string = "bar" @@ -25,13 +25,13 @@ final class NSObjectTests: XCTestCase { func testObjectsWillBeDeallocatedSignal() { - let expectation = self.expectationWithDescription("Expected timer to send `completed` event when object deallocates") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected timer to send `completed` event when object deallocates") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } let object = Object() - timer(1, onScheduler: QueueScheduler(name: "test.queue")) - .takeUntil(object.rex_willDealloc) + timer(interval: 1, on: QueueScheduler(name: "test.queue")) + .take(until: object.rex_willDealloc) .startWithCompleted { expectation.fulfill() } diff --git a/Tests/Helpers/UIControl+EnableSendActionsForControlEvents.swift b/Tests/Helpers/UIControl+EnableSendActionsForControlEvents.swift index 24d5db1..9bd716b 100644 --- a/Tests/Helpers/UIControl+EnableSendActionsForControlEvents.swift +++ b/Tests/Helpers/UIControl+EnableSendActionsForControlEvents.swift @@ -8,6 +8,30 @@ import UIKit +private let rex_swizzleToken: Void = { + let originalSelector = #selector(UIControl.sendAction(_:to:for:)) + let swizzledSelector = #selector(UIControl.rex_sendAction(_:to:forEvent:)) + + let originalMethod = class_getInstanceMethod(UIControl.self, originalSelector) + let swizzledMethod = class_getInstanceMethod(UIControl.self, swizzledSelector) + + let didAddMethod = class_addMethod(UIControl.self, + originalSelector, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod)) + + if didAddMethod { + class_replaceMethod(UIControl.self, + swizzledSelector, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)) + } else { + method_exchangeImplementations(originalMethod, swizzledMethod) + } + + return () +}() + /// Unfortunately, there's an apparent limitation in using `sendActionsForControlEvents` /// on unit-tests for any control besides `UIButton` which is very unfortunate since we /// want test our bindings for `UIDatePicker`, `UISwitch`, `UITextField` and others @@ -16,42 +40,16 @@ import UIKit extension UIControl { public override class func initialize() { - - struct Static { - static var token: dispatch_once_t = 0 - } - if self !== UIControl.self { return } - dispatch_once(&Static.token) { - - let originalSelector = #selector(UIControl.sendAction(_:to:forEvent:)) - let swizzledSelector = #selector(UIControl.rex_sendAction(_:to:forEvent:)) - - let originalMethod = class_getInstanceMethod(self, originalSelector) - let swizzledMethod = class_getInstanceMethod(self, swizzledSelector) - - let didAddMethod = class_addMethod(self, - originalSelector, - method_getImplementation(swizzledMethod), - method_getTypeEncoding(swizzledMethod)) - - if didAddMethod { - class_replaceMethod(self, - swizzledSelector, - method_getImplementation(originalMethod), - method_getTypeEncoding(originalMethod)) - } else { - method_exchangeImplementations(originalMethod, swizzledMethod) - } - } + _ = rex_swizzleToken } // MARK: - Method Swizzling - func rex_sendAction(action: Selector, to target: AnyObject?, forEvent event: UIEvent?) { - target?.performSelector(action, withObject: self) + func rex_sendAction(_ action: Selector, to target: AnyObject?, forEvent event: UIEvent?) { + _ = target?.perform(action, with: self) } } diff --git a/Tests/PropertyTests.swift b/Tests/PropertyTests.swift index ea32ccb..6faedac 100644 --- a/Tests/PropertyTests.swift +++ b/Tests/PropertyTests.swift @@ -32,7 +32,7 @@ final class PropertyTests: XCTestCase { XCTAssertTrue(current!) let (signal, pipe) = Signal.pipe() - let and2 = and.and(AnyProperty(initialValue: false, signal: signal)) + let and2 = and.and(AnyProperty(initial: false, then: signal)) and2.producer.startWithNext { current = $0 } XCTAssertFalse(and2.value) @@ -62,7 +62,7 @@ final class PropertyTests: XCTestCase { XCTAssertFalse(current!) let (signal, pipe) = Signal.pipe() - let or2 = or.or(AnyProperty(initialValue: true, signal: signal)) + let or2 = or.or(AnyProperty(initial: true, then: signal)) or2.producer.startWithNext { current = $0 } XCTAssertTrue(or2.value) diff --git a/Tests/SignalProducerTests.swift b/Tests/SignalProducerTests.swift index 35ef801..997ad37 100644 --- a/Tests/SignalProducerTests.swift +++ b/Tests/SignalProducerTests.swift @@ -14,7 +14,9 @@ import enum Result.NoError final class SignalProducerTests: XCTestCase { func testGroupBy() { - let (producer, observer) = SignalProducer.buffer(Int.max) + let (signal, observer) = Signal.pipe() + let producer = SignalProducer(signal: signal) + var evens: [Int] = [] var odds: [Int] = [] let disposable = CompositeDisposable() @@ -22,7 +24,7 @@ final class SignalProducerTests: XCTestCase { var completed = false disposable += producer - .groupBy { $0 % 2 == 0 } + .group { $0 % 2 == 0 } .start(Observer(next: { key, group in if key { group.startWithNext { evens.append($0) } @@ -62,7 +64,7 @@ final class SignalProducerTests: XCTestCase { var started = false producer - .deferred(1, onScheduler: scheduler) + .defer(by: 1, on: scheduler) .on(started: { started = true }) .start() @@ -72,10 +74,10 @@ final class SignalProducerTests: XCTestCase { scheduler.advance() XCTAssertFalse(deferred) - scheduler.advanceByInterval(0.9) + scheduler.advance(by: 0.9) XCTAssertFalse(deferred) - scheduler.advanceByInterval(0.2) + scheduler.advance(by: 0.2) XCTAssertTrue(deferred) } @@ -86,7 +88,7 @@ final class SignalProducerTests: XCTestCase { let producer = SignalProducer { observer, _ in if count < 2 { scheduler.schedule { observer.sendNext(count) } - scheduler.schedule { observer.sendFailed(.Default) } + scheduler.schedule { observer.sendFailed(.default) } } else { scheduler.schedule { observer.sendCompleted() } } @@ -96,7 +98,7 @@ final class SignalProducerTests: XCTestCase { var value = -1 var completed = false producer - .deferredRetry(1, onScheduler: scheduler) + .deferredRetry(interval: 1, on: scheduler) .start(Observer( next: { value = $0 }, completed: { completed = true } @@ -110,12 +112,12 @@ final class SignalProducerTests: XCTestCase { XCTAssertEqual(value, 1) XCTAssertFalse(completed) - scheduler.advanceByInterval(1) + scheduler.advance(by: 1) XCTAssertEqual(count, 2) XCTAssertEqual(value, 2) XCTAssertFalse(completed) - scheduler.advanceByInterval(1) + scheduler.advance(by: 1) XCTAssertEqual(count, 3) XCTAssertEqual(value, 2) XCTAssertTrue(completed) @@ -127,14 +129,14 @@ final class SignalProducerTests: XCTestCase { var count = 0 let producer = SignalProducer { observer, _ in observer.sendNext(count) - observer.sendFailed(.Default) + observer.sendFailed(.default) count += 1 } var value = -1 var failed = false producer - .deferredRetry(1, onScheduler: scheduler, count: 2) + .deferredRetry(interval: 1, on: scheduler, count: 2) .start(Observer( next: { value = $0 }, failed: { _ in failed = true } @@ -148,12 +150,12 @@ final class SignalProducerTests: XCTestCase { XCTAssertEqual(value, 0) XCTAssertFalse(failed) - scheduler.advanceByInterval(1) + scheduler.advance(by: 1) XCTAssertEqual(count, 2) XCTAssertEqual(value, 1) XCTAssertFalse(failed) - scheduler.advanceByInterval(1) + scheduler.advance(by: 1) XCTAssertEqual(count, 3) XCTAssertEqual(value, 2) XCTAssertTrue(failed) diff --git a/Tests/SignalTests.swift b/Tests/SignalTests.swift index af55e1b..350e980 100644 --- a/Tests/SignalTests.swift +++ b/Tests/SignalTests.swift @@ -47,7 +47,7 @@ final class SignalTests: XCTestCase { observer.sendNext(1) XCTAssertFalse(completed) - observer.sendFailed(.Default) + observer.sendFailed(.default) XCTAssertTrue(completed) } @@ -56,13 +56,13 @@ final class SignalTests: XCTestCase { var interrupted = false signal - .ignoreError(replacement: .Interrupted) + .ignoreError(replacement: .interrupted) .observeInterrupted { interrupted = true } observer.sendNext(1) XCTAssertFalse(interrupted) - observer.sendFailed(.Default) + observer.sendFailed(.default) XCTAssertTrue(interrupted) } @@ -73,13 +73,13 @@ final class SignalTests: XCTestCase { var completed = false signal - .timeoutAfter(2, withEvent: .Interrupted, onScheduler: scheduler) + .timeout(after: 2, with: .interrupted, on: scheduler) .observe(Observer( completed: { completed = true }, interrupted: { interrupted = true } )) - scheduler.scheduleAfter(1) { observer.sendCompleted() } + scheduler.schedule(after: 1) { observer.sendCompleted() } XCTAssertFalse(interrupted) XCTAssertFalse(completed) @@ -96,13 +96,13 @@ final class SignalTests: XCTestCase { var completed = false signal - .timeoutAfter(2, withEvent: .Interrupted, onScheduler: scheduler) + .timeout(after: 2, with: .interrupted, on: scheduler) .observe(Observer( completed: { completed = true }, interrupted: { interrupted = true } )) - scheduler.scheduleAfter(3) { observer.sendCompleted() } + scheduler.schedule(after: 3) { observer.sendCompleted() } XCTAssertFalse(interrupted) XCTAssertFalse(completed) @@ -136,7 +136,7 @@ final class SignalTests: XCTestCase { var value = -1 signal - .muteFor(1, clock: scheduler) + .mute(for: 1, clock: scheduler) .observeNext { value = $0 } scheduler.schedule { observer.sendNext(1) } @@ -152,7 +152,7 @@ final class SignalTests: XCTestCase { scheduler.advance() XCTAssertEqual(value, 1) - scheduler.advanceByInterval(1) + scheduler.advance(by: 1) XCTAssertEqual(value, 1) scheduler.schedule { observer.sendNext(5) } @@ -168,7 +168,7 @@ final class SignalTests: XCTestCase { var failed = false signal - .muteFor(1, clock: scheduler) + .mute(for: 1, clock: scheduler) .observe(Observer( next: { value = $0 }, failed: { _ in failed = true } @@ -179,13 +179,13 @@ final class SignalTests: XCTestCase { XCTAssertEqual(value, 1) scheduler.schedule { observer.sendNext(2) } - scheduler.schedule { observer.sendFailed(.Default) } + scheduler.schedule { observer.sendFailed(.default) } scheduler.advance() XCTAssertTrue(failed) XCTAssertEqual(value, 1) } } -enum TestError: ErrorType { - case Default +enum TestError: ErrorProtocol { + case `default` } diff --git a/Tests/UIKit/UIActivityIndicatorViewTests.swift b/Tests/UIKit/UIActivityIndicatorViewTests.swift index d47d1cb..ece8aef 100644 --- a/Tests/UIKit/UIActivityIndicatorViewTests.swift +++ b/Tests/UIKit/UIActivityIndicatorViewTests.swift @@ -20,7 +20,7 @@ class UIActivityIndicatorTests: XCTestCase { } func testAnimatingProperty() { - let indicatorView = UIActivityIndicatorView(frame: CGRectZero) + let indicatorView = UIActivityIndicatorView(frame: CGRect.zero) _activityIndicatorView = indicatorView let (pipeSignal, observer) = Signal.pipe() diff --git a/Tests/UIKit/UIBarButtonItemTests.swift b/Tests/UIKit/UIBarButtonItemTests.swift index 8b65c36..d20553b 100644 --- a/Tests/UIKit/UIBarButtonItemTests.swift +++ b/Tests/UIKit/UIBarButtonItemTests.swift @@ -32,15 +32,15 @@ class UIBarButtonItemTests: XCTestCase { func testEnabledProperty() { let barButtonItem = UIBarButtonItem() - barButtonItem.enabled = true + barButtonItem.isEnabled = true let (pipeSignal, observer) = Signal.pipe() barButtonItem.rex_enabled <~ SignalProducer(signal: pipeSignal) observer.sendNext(false) - XCTAssertFalse(barButtonItem.enabled) + XCTAssertFalse(barButtonItem.isEnabled) observer.sendNext(true) - XCTAssertTrue(barButtonItem.enabled) + XCTAssertTrue(barButtonItem.isEnabled) } } diff --git a/Tests/UIKit/UIButtonTests.swift b/Tests/UIKit/UIButtonTests.swift index b8d33f7..e799e2e 100644 --- a/Tests/UIKit/UIButtonTests.swift +++ b/Tests/UIKit/UIButtonTests.swift @@ -13,12 +13,12 @@ import enum Result.NoError extension UIButton { static func button() -> UIButton { - let button = UIButton(type: UIButtonType.Custom) + let button = UIButton(type: UIButtonType.custom) return button; } - override public func sendAction(action: Selector, to target: AnyObject?, forEvent event: UIEvent?) { - target?.performSelector(action, withObject: nil) + override public func sendAction(_ action: Selector, to target: AnyObject?, for event: UIEvent?) { + target?.perform(action, with: nil) } } @@ -32,15 +32,15 @@ class UIButtonTests: XCTestCase { } func testEnabledPropertyDoesntCreateRetainCycle() { - let button = UIButton(frame: CGRectZero) + let button = UIButton(frame: CGRect.zero) _button = button button.rex_enabled <~ SignalProducer(value: false) - XCTAssert(_button?.enabled == false) + XCTAssert(_button?.isEnabled == false) } func testPressedPropertyDoesntCreateRetainCycle() { - let button = UIButton(frame: CGRectZero) + let button = UIButton(frame: CGRect.zero) _button = button let action = Action<(),(),NoError> { @@ -50,37 +50,37 @@ class UIButtonTests: XCTestCase { } func testTitlePropertyDoesntCreateRetainCycle() { - let button = UIButton(frame: CGRectZero) + let button = UIButton(frame: CGRect.zero) _button = button button.rex_title <~ SignalProducer(value: "button") - XCTAssert(_button?.titleForState(.Normal) == "button") + XCTAssert(_button?.title(for: UIControlState()) == "button") } func testTitleProperty() { let firstTitle = "First title" let secondTitle = "Second title" - let button = UIButton(frame: CGRectZero) + let button = UIButton(frame: CGRect.zero) let (pipeSignal, observer) = Signal.pipe() button.rex_title <~ SignalProducer(signal: pipeSignal) - button.setTitle("", forState: .Selected) - button.setTitle("", forState: .Highlighted) + button.setTitle("", for: .selected) + button.setTitle("", for: .highlighted) observer.sendNext(firstTitle) - XCTAssertEqual(button.titleForState(.Normal), firstTitle) - XCTAssertEqual(button.titleForState(.Highlighted), "") - XCTAssertEqual(button.titleForState(.Selected), "") + XCTAssertEqual(button.title(for: UIControlState()), firstTitle) + XCTAssertEqual(button.title(for: .highlighted), "") + XCTAssertEqual(button.title(for: .selected), "") observer.sendNext(secondTitle) - XCTAssertEqual(button.titleForState(.Normal), secondTitle) - XCTAssertEqual(button.titleForState(.Highlighted), "") - XCTAssertEqual(button.titleForState(.Selected), "") + XCTAssertEqual(button.title(for: UIControlState()), secondTitle) + XCTAssertEqual(button.title(for: .highlighted), "") + XCTAssertEqual(button.title(for: .selected), "") } func testPressedProperty() { - let button = UIButton(frame: CGRectZero) - button.enabled = true - button.userInteractionEnabled = true + let button = UIButton(frame: CGRect.zero) + button.isEnabled = true + button.isUserInteractionEnabled = true let passed = MutableProperty(false) let action = Action<(), Bool, NoError> { _ in @@ -90,7 +90,7 @@ class UIButtonTests: XCTestCase { passed <~ SignalProducer(signal: action.values) button.rex_pressed <~ SignalProducer(value: CocoaAction(action, input: ())) - button.sendActionsForControlEvents(.TouchUpInside) + button.sendActions(for: .touchUpInside) XCTAssertTrue(passed.value) diff --git a/Tests/UIKit/UICollectionReusableViewTests.swift b/Tests/UIKit/UICollectionReusableViewTests.swift index b95afac..c0f2a1e 100644 --- a/Tests/UIKit/UICollectionReusableViewTests.swift +++ b/Tests/UIKit/UICollectionReusableViewTests.swift @@ -17,19 +17,19 @@ class UICollectionReusableViewTests: XCTestCase { let cell = UICollectionViewCell() - cell.rex_hidden <~ + cell.bindables.isHidden <~ hiddenProperty .producer - .takeUntil(cell.rex_prepareForReuse) + .take(until: cell.rex_prepareForReuse) - XCTAssertFalse(cell.hidden) + XCTAssertFalse(cell.isHidden) hiddenProperty <~ SignalProducer(value: true) - XCTAssertTrue(cell.hidden) + XCTAssertTrue(cell.isHidden) cell.prepareForReuse() hiddenProperty <~ SignalProducer(value: false) - XCTAssertTrue(cell.hidden) + XCTAssertTrue(cell.isHidden) } } diff --git a/Tests/UIKit/UIControlTests.swift b/Tests/UIKit/UIControlTests.swift index b16bfe4..07f35d0 100644 --- a/Tests/UIKit/UIControlTests.swift +++ b/Tests/UIKit/UIControlTests.swift @@ -21,72 +21,72 @@ class UIControlTests: XCTestCase { } func testEnabledPropertyDoesntCreateRetainCycle() { - let control = UIControl(frame: CGRectZero) + let control = UIControl(frame: CGRect.zero) _control = control control.rex_enabled <~ SignalProducer(value: false) - XCTAssert(_control?.enabled == false) + XCTAssert(_control?.isEnabled == false) } func testSelectedPropertyDoesntCreateRetainCycle() { - let control = UIControl(frame: CGRectZero) + let control = UIControl(frame: CGRect.zero) _control = control control.rex_selected <~ SignalProducer(value: true) - XCTAssert(_control?.selected == true) + XCTAssert(_control?.isSelected == true) } func testHighlightedPropertyDoesntCreateRetainCycle() { - let control = UIControl(frame: CGRectZero) + let control = UIControl(frame: CGRect.zero) _control = control control.rex_highlighted <~ SignalProducer(value: true) - XCTAssert(_control?.highlighted == true) + XCTAssert(_control?.isHighlighted == true) } func testEnabledProperty () { - let control = UIControl(frame: CGRectZero) - control.enabled = false + let control = UIControl(frame: CGRect.zero) + control.isEnabled = false let (pipeSignal, observer) = Signal.pipe() control.rex_enabled <~ SignalProducer(signal: pipeSignal) observer.sendNext(true) - XCTAssertTrue(control.enabled) + XCTAssertTrue(control.isEnabled) observer.sendNext(false) - XCTAssertFalse(control.enabled) + XCTAssertFalse(control.isEnabled) } func testSelectedProperty() { - let control = UIControl(frame: CGRectZero) - control.selected = false + let control = UIControl(frame: CGRect.zero) + control.isSelected = false let (pipeSignal, observer) = Signal.pipe() control.rex_selected <~ SignalProducer(signal: pipeSignal) observer.sendNext(true) - XCTAssertTrue(control.selected) + XCTAssertTrue(control.isSelected) observer.sendNext(false) - XCTAssertFalse(control.selected) + XCTAssertFalse(control.isSelected) } func testHighlightedProperty() { - let control = UIControl(frame: CGRectZero) - control.highlighted = false + let control = UIControl(frame: CGRect.zero) + control.isHighlighted = false let (pipeSignal, observer) = Signal.pipe() control.rex_highlighted <~ SignalProducer(signal: pipeSignal) observer.sendNext(true) - XCTAssertTrue(control.highlighted) + XCTAssertTrue(control.isHighlighted) observer.sendNext(false) - XCTAssertFalse(control.highlighted) + XCTAssertFalse(control.isHighlighted) } func testEnabledAndSelectedProperty() { - let control = UIControl(frame: CGRectZero) - control.selected = false - control.enabled = false + let control = UIControl(frame: CGRect.zero) + control.isSelected = false + control.isEnabled = false let (pipeSignalSelected, observerSelected) = Signal.pipe() let (pipeSignalEnabled, observerEnabled) = Signal.pipe() @@ -95,13 +95,13 @@ class UIControlTests: XCTestCase { observerSelected.sendNext(true) observerEnabled.sendNext(true) - XCTAssertTrue(control.enabled) - XCTAssertTrue(control.selected) + XCTAssertTrue(control.isEnabled) + XCTAssertTrue(control.isSelected) observerSelected.sendNext(false) - XCTAssertTrue(control.enabled) - XCTAssertFalse(control.selected) + XCTAssertTrue(control.isEnabled) + XCTAssertFalse(control.isSelected) observerEnabled.sendNext(false) - XCTAssertFalse(control.enabled) - XCTAssertFalse(control.selected) + XCTAssertFalse(control.isEnabled) + XCTAssertFalse(control.isSelected) } } diff --git a/Tests/UIKit/UIDatePickerTests.swift b/Tests/UIKit/UIDatePickerTests.swift index f29dbd6..20ac37e 100644 --- a/Tests/UIKit/UIDatePickerTests.swift +++ b/Tests/UIKit/UIDatePickerTests.swift @@ -13,15 +13,15 @@ import Rex class UIDatePickerTests: XCTestCase { - var date: NSDate! + var date: Date! var picker: UIDatePicker! override func setUp() { - let formatter = NSDateFormatter() + let formatter = DateFormatter() formatter.dateFormat = "MM/dd/YYYY" - date = formatter.dateFromString("11/29/1988")! + date = formatter.date(from: "11/29/1988")! - picker = UIDatePicker(frame: CGRectZero) + picker = UIDatePicker(frame: CGRect.zero) } func testUpdatePickerFromProperty() { @@ -31,8 +31,8 @@ class UIDatePickerTests: XCTestCase { } func testUpdatePropertyFromPicker() { - let expectation = self.expectationWithDescription("Expected rex_date to send an event when picker's date value is changed by a UI event") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected rex_date to send an event when picker's date value is changed by a UI event") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } picker.rex_date.signal.observeNext { changedDate in XCTAssertEqual(changedDate, self.date) @@ -40,8 +40,8 @@ class UIDatePickerTests: XCTestCase { } picker.date = date - picker.enabled = true - picker.userInteractionEnabled = true - picker.sendActionsForControlEvents(.ValueChanged) + picker.isEnabled = true + picker.isUserInteractionEnabled = true + picker.sendActions(for: .valueChanged) } } diff --git a/Tests/UIKit/UIImageViewTests.swift b/Tests/UIKit/UIImageViewTests.swift index b632f51..b8f4e0f 100644 --- a/Tests/UIKit/UIImageViewTests.swift +++ b/Tests/UIKit/UIImageViewTests.swift @@ -21,7 +21,7 @@ class UIImageViewTests: XCTestCase { } func testImagePropertyDoesntCreateRetainCycle() { - let imageView = UIImageView(frame: CGRectZero) + let imageView = UIImageView(frame: CGRect.zero) _imageView = imageView let image = UIImage() @@ -31,7 +31,7 @@ class UIImageViewTests: XCTestCase { } func testHighlightedImagePropertyDoesntCreateRetainCycle() { - let imageView = UIImageView(frame: CGRectZero) + let imageView = UIImageView(frame: CGRect.zero) _imageView = imageView let image = UIImage() @@ -41,7 +41,7 @@ class UIImageViewTests: XCTestCase { } func testImageProperty() { - let imageView = UIImageView(frame: CGRectZero) + let imageView = UIImageView(frame: CGRect.zero) let firstChange = UIImage() let secondChange = UIImage() @@ -56,7 +56,7 @@ class UIImageViewTests: XCTestCase { } func testHighlightedImageProperty() { - let imageView = UIImageView(frame: CGRectZero) + let imageView = UIImageView(frame: CGRect.zero) let firstChange = UIImage() let secondChange = UIImage() diff --git a/Tests/UIKit/UILabelTests.swift b/Tests/UIKit/UILabelTests.swift index 9356b9f..ded0e7d 100644 --- a/Tests/UIKit/UILabelTests.swift +++ b/Tests/UIKit/UILabelTests.swift @@ -21,7 +21,7 @@ class UILabelTests: XCTestCase { } func testTextPropertyDoesntCreateRetainCycle() { - let label = UILabel(frame: CGRectZero) + let label = UILabel(frame: CGRect.zero) _label = label label.rex_text <~ SignalProducer(value: "Test") @@ -32,7 +32,7 @@ class UILabelTests: XCTestCase { let firstChange = "first" let secondChange = "second" - let label = UILabel(frame: CGRectZero) + let label = UILabel(frame: CGRect.zero) label.text = "" let (pipeSignal, observer) = Signal.pipe() @@ -47,21 +47,21 @@ class UILabelTests: XCTestCase { } func testAttributedTextPropertyDoesntCreateRetainCycle() { - let label = UILabel(frame: CGRectZero) + let label = UILabel(frame: CGRect.zero) _label = label - label.rex_attributedText <~ SignalProducer(value: NSAttributedString(string: "Test")) + label.rex_attributedText <~ SignalProducer(value: AttributedString(string: "Test")) XCTAssert(_label?.attributedText?.string == "Test") } func testAttributedTextProperty() { - let firstChange = NSAttributedString(string: "first") - let secondChange = NSAttributedString(string: "second") + let firstChange = AttributedString(string: "first") + let secondChange = AttributedString(string: "second") - let label = UILabel(frame: CGRectZero) - label.attributedText = NSAttributedString(string: "") + let label = UILabel(frame: CGRect.zero) + label.attributedText = AttributedString(string: "") - let (pipeSignal, observer) = Signal.pipe() + let (pipeSignal, observer) = Signal.pipe() label.rex_attributedText <~ SignalProducer(signal: pipeSignal) observer.sendNext(firstChange) @@ -71,13 +71,13 @@ class UILabelTests: XCTestCase { } func testTextColorProperty() { - let firstChange = UIColor.redColor() - let secondChange = UIColor.blackColor() + let firstChange = UIColor.red() + let secondChange = UIColor.black() - let label = UILabel(frame: CGRectZero) + let label = UILabel(frame: CGRect.zero) let (pipeSignal, observer) = Signal.pipe() - label.textColor = UIColor.blackColor() + label.textColor = UIColor.black() label.rex_textColor <~ SignalProducer(signal: pipeSignal) observer.sendNext(firstChange) diff --git a/Tests/UIKit/UIProgressViewTests.swift b/Tests/UIKit/UIProgressViewTests.swift index 4fbe695..9e81afd 100644 --- a/Tests/UIKit/UIProgressViewTests.swift +++ b/Tests/UIKit/UIProgressViewTests.swift @@ -20,7 +20,7 @@ class UIProgressViewTests: XCTestCase { } func testProgressPropertyDoesntCreateRetainCycle() { - let progressView = UIProgressView(frame: CGRectZero) + let progressView = UIProgressView(frame: CGRect.zero) _progressView = progressView progressView.rex_progress <~ SignalProducer(value: 0.5) @@ -31,7 +31,7 @@ class UIProgressViewTests: XCTestCase { let firstChange: Float = 0.5 let secondChange: Float = 0.0 - let progressView = UIProgressView(frame: CGRectZero) + let progressView = UIProgressView(frame: CGRect.zero) progressView.progress = 1.0 let (pipeSignal, observer) = Signal.pipe() diff --git a/Tests/UIKit/UISwitchTests.swift b/Tests/UIKit/UISwitchTests.swift index 9391052..5098ff7 100644 --- a/Tests/UIKit/UISwitchTests.swift +++ b/Tests/UIKit/UISwitchTests.swift @@ -13,19 +13,19 @@ import Result class UISwitchTests: XCTestCase { func testOnProperty() { - let `switch` = UISwitch(frame: CGRectZero) - `switch`.on = false + let `switch` = UISwitch(frame: CGRect.zero) + `switch`.isOn = false let (pipeSignal, observer) = Signal.pipe() `switch`.rex_on <~ SignalProducer(signal: pipeSignal) observer.sendNext(true) - XCTAssertTrue(`switch`.on) + XCTAssertTrue(`switch`.isOn) observer.sendNext(false) - XCTAssertFalse(`switch`.on) + XCTAssertFalse(`switch`.isOn) - `switch`.on = true - `switch`.sendActionsForControlEvents(.ValueChanged) + `switch`.isOn = true + `switch`.sendActions(for: .valueChanged) XCTAssertTrue(`switch`.rex_on.value) } } diff --git a/Tests/UIKit/UITableViewCellTests.swift b/Tests/UIKit/UITableViewCellTests.swift index d08767f..a6a4baa 100644 --- a/Tests/UIKit/UITableViewCellTests.swift +++ b/Tests/UIKit/UITableViewCellTests.swift @@ -24,8 +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 5. Reference: https://github.com/ReactiveCocoa/ReactiveCocoa/pull/2852 - .takeUntil(cell.rex_prepareForReuse) + .take(until: cell.rex_prepareForReuse) XCTAssertEqual(label.text, "John") diff --git a/Tests/UIKit/UITableViewHeaderFooterViewTests.swift b/Tests/UIKit/UITableViewHeaderFooterViewTests.swift index 8255e93..505d54a 100644 --- a/Tests/UIKit/UITableViewHeaderFooterViewTests.swift +++ b/Tests/UIKit/UITableViewHeaderFooterViewTests.swift @@ -17,19 +17,19 @@ class UITableViewHeaderFooterViewTests: XCTestCase { let header = UITableViewHeaderFooterView() - header.rex_hidden <~ + header.bindables.isHidden <~ hiddenProperty .producer - .takeUntil(header.rex_prepareForReuse) + .take(until: header.rex_prepareForReuse) - XCTAssertFalse(header.hidden) + XCTAssertFalse(header.isHidden) hiddenProperty <~ SignalProducer(value: true) - XCTAssertTrue(header.hidden) + XCTAssertTrue(header.isHidden) header.prepareForReuse() hiddenProperty <~ SignalProducer(value: false) - XCTAssertTrue(header.hidden) + XCTAssertTrue(header.isHidden) } } diff --git a/Tests/UIKit/UITextFieldTests.swift b/Tests/UIKit/UITextFieldTests.swift index fee8e85..588f4eb 100644 --- a/Tests/UIKit/UITextFieldTests.swift +++ b/Tests/UIKit/UITextFieldTests.swift @@ -13,10 +13,10 @@ import XCTest class UITextFieldTests: XCTestCase { func testTextProperty() { - let expectation = self.expectationWithDescription("Expected `rex_text`'s value to equal to the textField's text") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected `rex_text`'s value to equal to the textField's text") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } - let textField = UITextField(frame: CGRectZero) + let textField = UITextField(frame: CGRect.zero) textField.text = "Test" textField.rex_text.signal.observeNext { text in @@ -25,7 +25,7 @@ class UITextFieldTests: XCTestCase { } #if os(iOS) - textField.sendActionsForControlEvents(.EditingChanged) + textField.sendActions(for: .editingChanged) #else NSNotificationCenter.defaultCenter().postNotificationName(UITextFieldTextDidChangeNotification, object: textField) #endif diff --git a/Tests/UIKit/UITextViewTests.swift b/Tests/UIKit/UITextViewTests.swift index 2ae4fc5..6374fe5 100644 --- a/Tests/UIKit/UITextViewTests.swift +++ b/Tests/UIKit/UITextViewTests.swift @@ -13,10 +13,10 @@ import XCTest class UITextViewTests: XCTestCase { func testTextProperty() { - let expectation = self.expectationWithDescription("Expected `rex_text`'s value to equal to the textViews's text") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected `rex_text`'s value to equal to the textViews's text") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } - let textView = UITextView(frame: CGRectZero) + let textView = UITextView(frame: CGRect.zero) textView.text = "Test" textView.rex_text.startWithNext { text in @@ -24,6 +24,6 @@ class UITextViewTests: XCTestCase { expectation.fulfill() } - NSNotificationCenter.defaultCenter().postNotificationName(UITextViewTextDidChangeNotification, object: textView) + NotificationCenter.default.post(name: NSNotification.Name.UITextViewTextDidChange, object: textView) } } diff --git a/Tests/UIKit/UIViewControllerTests.swift b/Tests/UIKit/UIViewControllerTests.swift index 04bf211..9d371e2 100644 --- a/Tests/UIKit/UIViewControllerTests.swift +++ b/Tests/UIKit/UIViewControllerTests.swift @@ -22,8 +22,8 @@ class UIViewControllerTests: XCTestCase { func testViewDidDisappear() { - let expectation = self.expectationWithDescription("Expected rex_viewDidDisappear to be triggered") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected rex_viewDidDisappear to be triggered") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } let viewController = UIViewController() _viewController = viewController @@ -37,8 +37,8 @@ class UIViewControllerTests: XCTestCase { func testViewWillDisappear() { - let expectation = self.expectationWithDescription("Expected rex_viewWillDisappear to be triggered") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected rex_viewWillDisappear to be triggered") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } let viewController = UIViewController() _viewController = viewController @@ -52,8 +52,8 @@ class UIViewControllerTests: XCTestCase { func testViewDidAppear() { - let expectation = self.expectationWithDescription("Expected rex_viewDidAppear to be triggered") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected rex_viewDidAppear to be triggered") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } let viewController = UIViewController() _viewController = viewController @@ -67,8 +67,8 @@ class UIViewControllerTests: XCTestCase { func testViewWillAppear() { - let expectation = self.expectationWithDescription("Expected rex_viewWillAppear to be triggered") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected rex_viewWillAppear to be triggered") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } let viewController = UIViewController() _viewController = viewController @@ -82,8 +82,8 @@ class UIViewControllerTests: XCTestCase { func testDismissViewController_via_property() { - let expectation = self.expectationWithDescription("Expected rex_dismissModally to be triggered") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected rex_dismissModally to be triggered") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } let viewController = UIViewController() _viewController = viewController @@ -97,8 +97,8 @@ class UIViewControllerTests: XCTestCase { func testDismissViewController_via_cocoaDismiss() { - let expectation = self.expectationWithDescription("Expected rex_dismissModally to be triggered") - defer { self.waitForExpectationsWithTimeout(2, handler: nil) } + let expectation = self.expectation(withDescription: "Expected rex_dismissModally to be triggered") + defer { self.waitForExpectations(withTimeout: 2, handler: nil) } let viewController = UIViewController() _viewController = viewController @@ -107,6 +107,6 @@ class UIViewControllerTests: XCTestCase { expectation.fulfill() } - viewController.dismissViewControllerAnimated(true, completion: nil) + viewController.dismiss(animated: true, completion: nil) } } diff --git a/Tests/UIKit/UIViewTests.swift b/Tests/UIKit/UIViewTests.swift index acd51c3..2374d85 100644 --- a/Tests/UIKit/UIViewTests.swift +++ b/Tests/UIKit/UIViewTests.swift @@ -21,43 +21,43 @@ class UIViewTests: XCTestCase { } func testAlphaPropertyDoesntCreateRetainCycle() { - let view = UIView(frame: CGRectZero) + let view = UIView(frame: CGRect.zero) _view = view - view.rex_alpha <~ SignalProducer(value: 0.5) + view.bindables.alpha <~ SignalProducer(value: 0.5) XCTAssertEqualWithAccuracy(_view!.alpha, 0.5, accuracy: 0.01) } func testHiddenPropertyDoesntCreateRetainCycle() { - let view = UIView(frame: CGRectZero) + let view = UIView(frame: CGRect.zero) _view = view - view.rex_hidden <~ SignalProducer(value: true) - XCTAssert(_view?.hidden == true) + view.bindables.isHidden <~ SignalProducer(value: true) + XCTAssert(_view?.isHidden == true) } func testHiddenProperty() { - let view = UIView(frame: CGRectZero) - view.hidden = true + let view = UIView(frame: CGRect.zero) + view.isHidden = true let (pipeSignal, observer) = Signal.pipe() - view.rex_hidden <~ SignalProducer(signal: pipeSignal) + view.bindables.isHidden <~ SignalProducer(signal: pipeSignal) observer.sendNext(true) - XCTAssertTrue(view.hidden) + XCTAssertTrue(view.isHidden) observer.sendNext(false) - XCTAssertFalse(view.hidden) + XCTAssertFalse(view.isHidden) } func testAlphaProperty() { - let view = UIView(frame: CGRectZero) + let view = UIView(frame: CGRect.zero) view.alpha = 0.0 let firstChange = CGFloat(0.5) let secondChange = CGFloat(0.7) let (pipeSignal, observer) = Signal.pipe() - view.rex_alpha <~ SignalProducer(signal: pipeSignal) + view.bindables.alpha <~ SignalProducer(signal: pipeSignal) observer.sendNext(firstChange) XCTAssertEqualWithAccuracy(view.alpha, firstChange, accuracy: 0.01) @@ -66,15 +66,15 @@ class UIViewTests: XCTestCase { } func testUserInteractionEnabledProperty() { - let view = UIView(frame: CGRectZero) - view.userInteractionEnabled = true + let view = UIView(frame: CGRect.zero) + view.isUserInteractionEnabled = true let (pipeSignal, observer) = Signal.pipe() - view.rex_userInteractionEnabled <~ SignalProducer(signal: pipeSignal) + view.bindables.isUserInteractionEnabled <~ SignalProducer(signal: pipeSignal) observer.sendNext(true) - XCTAssertTrue(view.userInteractionEnabled) + XCTAssertTrue(view.isUserInteractionEnabled) observer.sendNext(false) - XCTAssertFalse(view.userInteractionEnabled) + XCTAssertFalse(view.isUserInteractionEnabled) } }