diff --git a/.gitmodules b/.gitmodules index 17cea48..94bdaa6 100644 --- a/.gitmodules +++ b/.gitmodules @@ -3,4 +3,4 @@ url = https://github.com/JohnSundell/Unbox.git [submodule "Carthage/Checkouts/Alamofire"] path = Carthage/Checkouts/Alamofire - url = https://github.com/Alamofire/Alamofire + url = https://github.com/Alamofire/Alamofire.git diff --git a/.swift-version b/.swift-version new file mode 100644 index 0000000..f398a20 --- /dev/null +++ b/.swift-version @@ -0,0 +1 @@ +3.0 \ No newline at end of file diff --git a/.travis.yml b/.travis.yml index 8a2c3b4..da73bc6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode7.3 +osx_image: xcode8 env: global: diff --git a/Cartfile b/Cartfile index 3499bfa..edd7f4c 100755 --- a/Cartfile +++ b/Cartfile @@ -1,2 +1,2 @@ -github "Alamofire/Alamofire" ~> 3.0 -github "JohnSundell/Unbox" ~> 1.5 \ No newline at end of file +github "Alamofire/Alamofire" ~> 4.0 +github "JohnSundell/Unbox" ~> 2.0 \ No newline at end of file diff --git a/Cartfile.resolved b/Cartfile.resolved index 92140b7..5c390a6 100644 --- a/Cartfile.resolved +++ b/Cartfile.resolved @@ -1,2 +1,2 @@ -github "Alamofire/Alamofire" "3.4.1" -github "JohnSundell/Unbox" "1.9" +github "Alamofire/Alamofire" "4.0.1" +github "JohnSundell/Unbox" "2.0" diff --git a/Carthage/Checkouts/Alamofire b/Carthage/Checkouts/Alamofire index 0f506b1..668cc5a 160000 --- a/Carthage/Checkouts/Alamofire +++ b/Carthage/Checkouts/Alamofire @@ -1 +1 @@ -Subproject commit 0f506b1c455e5ce4312d27daeb98c10a608107d3 +Subproject commit 668cc5a064b09dcbcfa28ce1c878ad0fde3f6e35 diff --git a/Carthage/Checkouts/Unbox b/Carthage/Checkouts/Unbox index f9c5a63..0e9c7cf 160000 --- a/Carthage/Checkouts/Unbox +++ b/Carthage/Checkouts/Unbox @@ -1 +1 @@ -Subproject commit f9c5a63d1ec1b3b4ed32fa8b5211c63a3d449899 +Subproject commit 0e9c7cf39a7c5d92ea6ef45e292ab7cdf728dce0 diff --git a/README.md b/README.md index 88dbe0a..14feb29 100755 --- a/README.md +++ b/README.md @@ -15,6 +15,8 @@ - [x] Mapping response to array of objects - [x] Keypaths - [x] Nested keypaths +- [x] For Swift 2.x use v. `1.x` and [swift2](https://github.com/serejahh/UnboxedAlamofire/tree/swift2) branch +- [x] For Swift 3.x use v. `2.x` ## Usage @@ -23,7 +25,7 @@ Objects you request have to conform [Unboxable](https://github.com/JohnSundell/U ### Get an object ``` swift -Alamofire.request(.GET, url).responseObject { (response: Response) in +Alamofire.request(url, method: .get).responseObject { (response: DataResponse) in let candy = response.result.value } ``` @@ -31,7 +33,7 @@ Alamofire.request(.GET, url).responseObject { (response: Response) in +Alamofire.request(url, method: .get).responseArray { (response: DataResponse<[Candy]>) in let candies = response.result.value } ``` @@ -41,7 +43,7 @@ Alamofire.request(.GET, url).responseArray { (response: Response<[Candy], NSErro Also you can specify a keypath in both requests: ``` swift -Alamofire.request(.GET, url).responseObject(keyPath: "response") { (response: Response) in +Alamofire.request(url, method: .get).responseObject(keyPath: "response") { (response: DataResponse) in let candy = response.result.value } ``` @@ -51,11 +53,11 @@ Alamofire.request(.GET, url).responseObject(keyPath: "response") { (response: Re ### [CocoaPods](https://cocoapods.org/) ``` -pod 'UnboxedAlamofire', '~> 1.0' +pod 'UnboxedAlamofire', '~> 2.0' ``` ### [Carthage](https://github.com/Carthage/Carthage) ``` -github "serejahh/UnboxedAlamofire" ~> 1.0 +github "serejahh/UnboxedAlamofire" ~> 2.0 ``` diff --git a/UnboxedAlamofire.podspec b/UnboxedAlamofire.podspec index dd028cc..2a6e93d 100755 --- a/UnboxedAlamofire.podspec +++ b/UnboxedAlamofire.podspec @@ -1,19 +1,19 @@ Pod::Spec.new do |s| s.name = "UnboxedAlamofire" - s.version = "1.0.1" + s.version = "2.0" s.license = { :type => "MIT", :file => "LICENSE" } s.summary = "Alamofire + Unbox: the easiest way to download and decode JSON into swift objects." s.homepage = "https://github.com/serejahh/UnboxedAlamofire" s.author = { "Serhii Butenko" => "sereja.butenko@gmail.com" } - s.source = { :git => 'https://github.com/serejahh/UnboxedAlamofire.git', :tag => s.version.to_s } + s.source = { :git => 'https://github.com/serejahh/UnboxedAlamofire.git', :tag => s.version } - s.ios.deployment_target = '8.0' - s.osx.deployment_target = '10.10' + s.ios.deployment_target = '9.0' + s.osx.deployment_target = '10.11' s.watchos.deployment_target = '2.0' s.tvos.deployment_target = '9.0' s.requires_arc = 'true' s.source_files = 'UnboxedAlamofire/**/*.swift' - s.dependency 'Alamofire', '~> 3.0' - s.dependency 'Unbox', '~> 1.5' + s.dependency 'Alamofire', '~> 4.0' + s.dependency 'Unbox', '~> 2.0' end diff --git a/UnboxedAlamofire.xcodeproj/project.pbxproj b/UnboxedAlamofire.xcodeproj/project.pbxproj index df0ab22..72222ce 100644 --- a/UnboxedAlamofire.xcodeproj/project.pbxproj +++ b/UnboxedAlamofire.xcodeproj/project.pbxproj @@ -15,7 +15,7 @@ C58251E41D4FC2EF009DC108 /* Unbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C58251E21D4FC2EF009DC108 /* Unbox.framework */; }; C5CDBA231D50A5B800992A82 /* Alamofire.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C58251E11D4FC2EF009DC108 /* Alamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C5CDBA241D50A5B800992A82 /* Unbox.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C58251E21D4FC2EF009DC108 /* Unbox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - C5CDBA251D50A5B800992A82 /* UnboxedAlamofire_iOS.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C52A5D341D4F699100AB86C6 /* UnboxedAlamofire_iOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + C5CDBA251D50A5B800992A82 /* UnboxedAlamofire.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C52A5D341D4F699100AB86C6 /* UnboxedAlamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C5CDBA281D50A5E000992A82 /* UnboxedAlamofire.swift in Sources */ = {isa = PBXBuildFile; fileRef = C58251DD1D4FC06F009DC108 /* UnboxedAlamofire.swift */; }; C5CDBA2A1D50A5E000992A82 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C58251E11D4FC2EF009DC108 /* Alamofire.framework */; }; C5CDBA2B1D50A5E000992A82 /* Unbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C58251E21D4FC2EF009DC108 /* Unbox.framework */; }; @@ -34,39 +34,39 @@ C5CDBA581D50A61700992A82 /* Unbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C58251E21D4FC2EF009DC108 /* Unbox.framework */; }; C5CDBA5B1D50A61700992A82 /* Alamofire.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C58251E11D4FC2EF009DC108 /* Alamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C5CDBA5C1D50A61700992A82 /* Unbox.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C58251E21D4FC2EF009DC108 /* Unbox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - C5CDBA5D1D50A61700992A82 /* UnboxedAlamofire_iOS.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C52A5D341D4F699100AB86C6 /* UnboxedAlamofire_iOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + C5CDBA5D1D50A61700992A82 /* UnboxedAlamofire.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C52A5D341D4F699100AB86C6 /* UnboxedAlamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C5CDBA671D50A62600992A82 /* UnboxedAlamofireTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = C52A5D431D4F699100AB86C6 /* UnboxedAlamofireTests.swift */; }; C5CDBA681D50A62600992A82 /* Candy.swift in Sources */ = {isa = PBXBuildFile; fileRef = C58251DF1D4FC076009DC108 /* Candy.swift */; }; C5CDBA6A1D50A62600992A82 /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C58251E11D4FC2EF009DC108 /* Alamofire.framework */; }; C5CDBA6B1D50A62600992A82 /* Unbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C58251E21D4FC2EF009DC108 /* Unbox.framework */; }; C5CDBA6E1D50A62600992A82 /* Alamofire.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C58251E11D4FC2EF009DC108 /* Alamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C5CDBA6F1D50A62600992A82 /* Unbox.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C58251E21D4FC2EF009DC108 /* Unbox.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; - C5CDBA701D50A62600992A82 /* UnboxedAlamofire_iOS.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C52A5D341D4F699100AB86C6 /* UnboxedAlamofire_iOS.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; + C5CDBA701D50A62600992A82 /* UnboxedAlamofire.framework in CopyFiles */ = {isa = PBXBuildFile; fileRef = C52A5D341D4F699100AB86C6 /* UnboxedAlamofire.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; C5DF8C961D50A1250059100F /* Alamofire.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C58251E11D4FC2EF009DC108 /* Alamofire.framework */; }; C5DF8C971D50A1250059100F /* Unbox.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C58251E21D4FC2EF009DC108 /* Unbox.framework */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ - C52A5D401D4F699100AB86C6 /* PBXContainerItemProxy */ = { + C541FEF01D93F03E00FBA7B8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = C52A5D2B1D4F699100AB86C6 /* Project object */; proxyType = 1; remoteGlobalIDString = C52A5D331D4F699100AB86C6; - remoteInfo = UnboxedAlamofire; + remoteInfo = UnboxedAlamofire_iOS; }; - C5CDBA521D50A61700992A82 /* PBXContainerItemProxy */ = { + C541FEF21D93F05100FBA7B8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = C52A5D2B1D4F699100AB86C6 /* Project object */; proxyType = 1; - remoteGlobalIDString = C52A5D331D4F699100AB86C6; - remoteInfo = UnboxedAlamofire; + remoteGlobalIDString = C5CDBA261D50A5E000992A82; + remoteInfo = UnboxedAlamofire_macOS; }; - C5CDBA651D50A62600992A82 /* PBXContainerItemProxy */ = { + C541FEF41D93F05700FBA7B8 /* PBXContainerItemProxy */ = { isa = PBXContainerItemProxy; containerPortal = C52A5D2B1D4F699100AB86C6 /* Project object */; proxyType = 1; - remoteGlobalIDString = C52A5D331D4F699100AB86C6; - remoteInfo = UnboxedAlamofire; + remoteGlobalIDString = C5CDBA421D50A5F000992A82; + remoteInfo = UnboxedAlamofire_tvOS; }; /* End PBXContainerItemProxy section */ @@ -79,7 +79,7 @@ files = ( C5CDBA231D50A5B800992A82 /* Alamofire.framework in CopyFiles */, C5CDBA241D50A5B800992A82 /* Unbox.framework in CopyFiles */, - C5CDBA251D50A5B800992A82 /* UnboxedAlamofire_iOS.framework in CopyFiles */, + C5CDBA251D50A5B800992A82 /* UnboxedAlamofire.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -91,7 +91,7 @@ files = ( C5CDBA5B1D50A61700992A82 /* Alamofire.framework in CopyFiles */, C5CDBA5C1D50A61700992A82 /* Unbox.framework in CopyFiles */, - C5CDBA5D1D50A61700992A82 /* UnboxedAlamofire_iOS.framework in CopyFiles */, + C5CDBA5D1D50A61700992A82 /* UnboxedAlamofire.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -103,14 +103,14 @@ files = ( C5CDBA6E1D50A62600992A82 /* Alamofire.framework in CopyFiles */, C5CDBA6F1D50A62600992A82 /* Unbox.framework in CopyFiles */, - C5CDBA701D50A62600992A82 /* UnboxedAlamofire_iOS.framework in CopyFiles */, + C5CDBA701D50A62600992A82 /* UnboxedAlamofire.framework in CopyFiles */, ); runOnlyForDeploymentPostprocessing = 0; }; /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - C52A5D341D4F699100AB86C6 /* UnboxedAlamofire_iOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UnboxedAlamofire_iOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C52A5D341D4F699100AB86C6 /* UnboxedAlamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UnboxedAlamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C52A5D371D4F699100AB86C6 /* UnboxedAlamofire.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UnboxedAlamofire.h; sourceTree = ""; }; C52A5D3E1D4F699100AB86C6 /* UnboxedAlamofire_iOS_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnboxedAlamofire_iOS_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C52A5D431D4F699100AB86C6 /* UnboxedAlamofireTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = UnboxedAlamofireTests.swift; sourceTree = ""; }; @@ -118,9 +118,9 @@ C58251DF1D4FC076009DC108 /* Candy.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Candy.swift; sourceTree = ""; }; C58251E11D4FC2EF009DC108 /* Alamofire.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Alamofire.framework; path = Carthage/Build/iOS/Alamofire.framework; sourceTree = ""; }; C58251E21D4FC2EF009DC108 /* Unbox.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Unbox.framework; path = Carthage/Build/iOS/Unbox.framework; sourceTree = ""; }; - C5CDBA321D50A5E000992A82 /* UnboxedAlamofire_macOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UnboxedAlamofire_macOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - C5CDBA401D50A5E900992A82 /* UnboxedAlamofire_watchOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UnboxedAlamofire_watchOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; - C5CDBA4E1D50A5F000992A82 /* UnboxedAlamofire_tvOS.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UnboxedAlamofire_tvOS.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C5CDBA321D50A5E000992A82 /* UnboxedAlamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UnboxedAlamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C5CDBA401D50A5E900992A82 /* UnboxedAlamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UnboxedAlamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; + C5CDBA4E1D50A5F000992A82 /* UnboxedAlamofire.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = UnboxedAlamofire.framework; sourceTree = BUILT_PRODUCTS_DIR; }; C5CDBA611D50A61700992A82 /* UnboxedAlamofire_macOS_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnboxedAlamofire_macOS_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C5CDBA741D50A62600992A82 /* UnboxedAlamofire_tvOS_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UnboxedAlamofire_tvOS_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; C5CDBA9D1D50D9D200992A82 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; @@ -207,11 +207,11 @@ C52A5D351D4F699100AB86C6 /* Products */ = { isa = PBXGroup; children = ( - C52A5D341D4F699100AB86C6 /* UnboxedAlamofire_iOS.framework */, + C52A5D341D4F699100AB86C6 /* UnboxedAlamofire.framework */, C52A5D3E1D4F699100AB86C6 /* UnboxedAlamofire_iOS_Tests.xctest */, - C5CDBA321D50A5E000992A82 /* UnboxedAlamofire_macOS.framework */, - C5CDBA401D50A5E900992A82 /* UnboxedAlamofire_watchOS.framework */, - C5CDBA4E1D50A5F000992A82 /* UnboxedAlamofire_tvOS.framework */, + C5CDBA321D50A5E000992A82 /* UnboxedAlamofire.framework */, + C5CDBA401D50A5E900992A82 /* UnboxedAlamofire.framework */, + C5CDBA4E1D50A5F000992A82 /* UnboxedAlamofire.framework */, C5CDBA611D50A61700992A82 /* UnboxedAlamofire_macOS_Tests.xctest */, C5CDBA741D50A62600992A82 /* UnboxedAlamofire_tvOS_Tests.xctest */, ); @@ -300,7 +300,7 @@ ); name = UnboxedAlamofire_iOS; productName = UnboxedAlamofire; - productReference = C52A5D341D4F699100AB86C6 /* UnboxedAlamofire_iOS.framework */; + productReference = C52A5D341D4F699100AB86C6 /* UnboxedAlamofire.framework */; productType = "com.apple.product-type.framework"; }; C52A5D3D1D4F699100AB86C6 /* UnboxedAlamofire_iOS_Tests */ = { @@ -315,7 +315,7 @@ buildRules = ( ); dependencies = ( - C52A5D411D4F699100AB86C6 /* PBXTargetDependency */, + C541FEF11D93F03E00FBA7B8 /* PBXTargetDependency */, ); name = UnboxedAlamofire_iOS_Tests; productName = UnboxedAlamofireTests; @@ -337,7 +337,7 @@ ); name = UnboxedAlamofire_macOS; productName = UnboxedAlamofire; - productReference = C5CDBA321D50A5E000992A82 /* UnboxedAlamofire_macOS.framework */; + productReference = C5CDBA321D50A5E000992A82 /* UnboxedAlamofire.framework */; productType = "com.apple.product-type.framework"; }; C5CDBA341D50A5E900992A82 /* UnboxedAlamofire_watchOS */ = { @@ -355,7 +355,7 @@ ); name = UnboxedAlamofire_watchOS; productName = UnboxedAlamofire; - productReference = C5CDBA401D50A5E900992A82 /* UnboxedAlamofire_watchOS.framework */; + productReference = C5CDBA401D50A5E900992A82 /* UnboxedAlamofire.framework */; productType = "com.apple.product-type.framework"; }; C5CDBA421D50A5F000992A82 /* UnboxedAlamofire_tvOS */ = { @@ -373,7 +373,7 @@ ); name = UnboxedAlamofire_tvOS; productName = UnboxedAlamofire; - productReference = C5CDBA4E1D50A5F000992A82 /* UnboxedAlamofire_tvOS.framework */; + productReference = C5CDBA4E1D50A5F000992A82 /* UnboxedAlamofire.framework */; productType = "com.apple.product-type.framework"; }; C5CDBA501D50A61700992A82 /* UnboxedAlamofire_macOS_Tests */ = { @@ -388,7 +388,7 @@ buildRules = ( ); dependencies = ( - C5CDBA511D50A61700992A82 /* PBXTargetDependency */, + C541FEF31D93F05100FBA7B8 /* PBXTargetDependency */, ); name = UnboxedAlamofire_macOS_Tests; productName = UnboxedAlamofireTests; @@ -407,7 +407,7 @@ buildRules = ( ); dependencies = ( - C5CDBA641D50A62600992A82 /* PBXTargetDependency */, + C541FEF51D93F05700FBA7B8 /* PBXTargetDependency */, ); name = UnboxedAlamofire_tvOS_Tests; productName = UnboxedAlamofireTests; @@ -421,14 +421,16 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0730; - LastUpgradeCheck = 0730; + LastUpgradeCheck = 0800; ORGANIZATIONNAME = "Serhii Butenko"; TargetAttributes = { C52A5D331D4F699100AB86C6 = { CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 0800; }; C52A5D3D1D4F699100AB86C6 = { CreatedOnToolsVersion = 7.3.1; + LastSwiftMigration = 0800; }; }; }; @@ -570,20 +572,20 @@ /* End PBXSourcesBuildPhase section */ /* Begin PBXTargetDependency section */ - C52A5D411D4F699100AB86C6 /* PBXTargetDependency */ = { + C541FEF11D93F03E00FBA7B8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; target = C52A5D331D4F699100AB86C6 /* UnboxedAlamofire_iOS */; - targetProxy = C52A5D401D4F699100AB86C6 /* PBXContainerItemProxy */; + targetProxy = C541FEF01D93F03E00FBA7B8 /* PBXContainerItemProxy */; }; - C5CDBA511D50A61700992A82 /* PBXTargetDependency */ = { + C541FEF31D93F05100FBA7B8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = C52A5D331D4F699100AB86C6 /* UnboxedAlamofire_iOS */; - targetProxy = C5CDBA521D50A61700992A82 /* PBXContainerItemProxy */; + target = C5CDBA261D50A5E000992A82 /* UnboxedAlamofire_macOS */; + targetProxy = C541FEF21D93F05100FBA7B8 /* PBXContainerItemProxy */; }; - C5CDBA641D50A62600992A82 /* PBXTargetDependency */ = { + C541FEF51D93F05700FBA7B8 /* PBXTargetDependency */ = { isa = PBXTargetDependency; - target = C52A5D331D4F699100AB86C6 /* UnboxedAlamofire_iOS */; - targetProxy = C5CDBA651D50A62600992A82 /* PBXContainerItemProxy */; + target = C5CDBA421D50A5F000992A82 /* UnboxedAlamofire_tvOS */; + targetProxy = C541FEF41D93F05700FBA7B8 /* PBXContainerItemProxy */; }; /* End PBXTargetDependency section */ @@ -602,8 +604,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -626,11 +630,13 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -651,8 +657,10 @@ CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; CLANG_WARN_EMPTY_BODY = YES; CLANG_WARN_ENUM_CONVERSION = YES; + CLANG_WARN_INFINITE_RECURSION = YES; CLANG_WARN_INT_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_SUSPICIOUS_MOVE = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; @@ -669,9 +677,12 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.3; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; + MACOSX_DEPLOYMENT_TARGET = 10.11; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; + SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -683,6 +694,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -693,12 +705,13 @@ ); INFOPLIST_FILE = UnboxedAlamofire/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofire; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = UnboxedAlamofire; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -706,6 +719,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -716,11 +730,12 @@ ); INFOPLIST_FILE = UnboxedAlamofire/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; - IPHONEOS_DEPLOYMENT_TARGET = 8.0; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofire; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = UnboxedAlamofire; SKIP_INSTALL = YES; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -736,6 +751,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofireTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -751,6 +767,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofireTests; PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -771,7 +788,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofire; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = UnboxedAlamofire; SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -795,7 +812,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofire; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = UnboxedAlamofire; SDKROOT = macosx; SKIP_INSTALL = YES; }; @@ -805,6 +822,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -817,10 +835,11 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofire; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = UnboxedAlamofire; SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Debug; }; @@ -828,6 +847,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=watchos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -840,9 +860,10 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofire; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = UnboxedAlamofire; SDKROOT = watchos; SKIP_INSTALL = YES; + WATCHOS_DEPLOYMENT_TARGET = 2.0; }; name = Release; }; @@ -850,6 +871,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -862,7 +884,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofire; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = UnboxedAlamofire; SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; @@ -874,6 +896,7 @@ isa = XCBuildConfiguration; buildSettings = { CLANG_ENABLE_MODULES = YES; + "CODE_SIGN_IDENTITY[sdk=appletvos*]" = ""; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; DYLIB_CURRENT_VERSION = 1; @@ -886,7 +909,7 @@ INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.cocoapods.UnboxedAlamofire; - PRODUCT_NAME = "$(TARGET_NAME)"; + PRODUCT_NAME = UnboxedAlamofire; SDKROOT = appletvos; SKIP_INSTALL = YES; TVOS_DEPLOYMENT_TARGET = 9.0; diff --git a/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-iOS.xcscheme b/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-iOS.xcscheme index c6d9cfc..6224477 100644 --- a/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-iOS.xcscheme +++ b/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-iOS.xcscheme @@ -1,6 +1,6 @@ @@ -43,7 +43,7 @@ @@ -65,7 +65,7 @@ @@ -83,7 +83,7 @@ diff --git a/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-macOS.xcscheme b/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-macOS.xcscheme index 35fac11..73a2fa4 100644 --- a/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-macOS.xcscheme +++ b/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-macOS.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +46,7 @@ @@ -64,7 +64,7 @@ diff --git a/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-tvOS.xcscheme b/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-tvOS.xcscheme index 98d4331..905606b 100644 --- a/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-tvOS.xcscheme +++ b/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-tvOS.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +46,7 @@ @@ -64,7 +64,7 @@ diff --git a/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-watchOS.xcscheme b/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-watchOS.xcscheme index b61402f..12c8a5f 100644 --- a/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-watchOS.xcscheme +++ b/UnboxedAlamofire.xcodeproj/xcshareddata/xcschemes/UnboxedAlamofire-watchOS.xcscheme @@ -1,6 +1,6 @@ @@ -46,7 +46,7 @@ @@ -64,7 +64,7 @@ diff --git a/UnboxedAlamofire/Info.plist b/UnboxedAlamofire/Info.plist index d3de8ee..dfb6492 100644 --- a/UnboxedAlamofire/Info.plist +++ b/UnboxedAlamofire/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0 + 2.0 CFBundleSignature ???? CFBundleVersion diff --git a/UnboxedAlamofire/UnboxedAlamofire.h b/UnboxedAlamofire/UnboxedAlamofire.h index d2c45d2..376bfce 100644 --- a/UnboxedAlamofire/UnboxedAlamofire.h +++ b/UnboxedAlamofire/UnboxedAlamofire.h @@ -6,7 +6,7 @@ // Copyright © 2016 Serhii Butenko. All rights reserved. // -#import +#import //! Project version number for UnboxedAlamofire. FOUNDATION_EXPORT double UnboxedAlamofireVersionNumber; @@ -15,5 +15,3 @@ FOUNDATION_EXPORT double UnboxedAlamofireVersionNumber; FOUNDATION_EXPORT const unsigned char UnboxedAlamofireVersionString[]; // In this header, you should import all the public headers of your framework using statements like #import - - diff --git a/UnboxedAlamofire/UnboxedAlamofire.swift b/UnboxedAlamofire/UnboxedAlamofire.swift index dc1a928..0e4d906 100644 --- a/UnboxedAlamofire/UnboxedAlamofire.swift +++ b/UnboxedAlamofire/UnboxedAlamofire.swift @@ -12,20 +12,21 @@ import Unbox // MARK: - Requests -extension Request { +extension DataRequest { /** Adds a handler to be called once the request has finished. - parameter queue: The queue on which the completion handler is dispatched. - parameter keyPath: The key path where object mapping should be performed. - - parameter options: The JSON serialization reading options. `.AllowFragments` by default. + - parameter options: The JSON serialization reading options. `.allowFragments` by default. - parameter completionHandler: A closure to be executed once the request has finished and the data has been mapped by Unbox. - returns: The request. */ - public func responseObject(queue queue: dispatch_queue_t? = nil, keyPath: String? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: Response -> Void) -> Self { - return response(queue: queue, responseSerializer: Request.UnboxObjectSerializer(options, keyPath: keyPath), completionHandler: completionHandler) + @discardableResult + public func responseObject(queue: DispatchQueue? = nil, keyPath: String? = nil, options: JSONSerialization.ReadingOptions = .allowFragments, completionHandler: @escaping (DataResponse) -> Void) -> Self { + return response(queue: queue, responseSerializer: DataRequest.UnboxObjectSerializer(options, keyPath: keyPath), completionHandler: completionHandler) } /** @@ -33,13 +34,14 @@ extension Request { - parameter queue: The queue on which the completion handler is dispatched. - parameter keyPath: The key path where object mapping should be performed. - - parameter options: The JSON serialization reading options. `.AllowFragments` by default. + - parameter options: The JSON serialization reading options. `.allowFragments` by default. - parameter completionHandler: A closure to be executed once the request has finished and the data has been mapped by Unbox. - returns: The request. */ - public func responseArray(queue queue: dispatch_queue_t? = nil, keyPath: String? = nil, options: NSJSONReadingOptions = .AllowFragments, completionHandler: Response<[T], NSError> -> Void) -> Self { - return response(queue: queue, responseSerializer: Request.UnboxArraySerializer(options, keyPath: keyPath), completionHandler: completionHandler) + @discardableResult + public func responseArray(queue: DispatchQueue? = nil, keyPath: String? = nil, options: JSONSerialization.ReadingOptions = .allowFragments, completionHandler: @escaping (DataResponse<[T]>) -> Void) -> Self { + return response(queue: queue, responseSerializer: DataRequest.UnboxArraySerializer(options, keyPath: keyPath), completionHandler: completionHandler) } } @@ -47,62 +49,62 @@ extension Request { private extension Request { - static func UnboxObjectSerializer(options: NSJSONReadingOptions, keyPath: String?) -> ResponseSerializer { - return ResponseSerializer { request, response, data, error in + static func UnboxObjectSerializer(_ options: JSONSerialization.ReadingOptions, keyPath: String?) -> DataResponseSerializer { + return DataResponseSerializer { request, response, data, error in if let error = error { - return .Failure(error) + return .failure(error) } - let JSONResponseSerializer = Request.JSONResponseSerializer(options: .AllowFragments) + let JSONResponseSerializer = DataRequest.jsonResponseSerializer(options: .allowFragments) let result = JSONResponseSerializer.serializeResponse(request, response, data, error) - let jsonCandidate: AnyObject? - if let keyPath = keyPath where !keyPath.isEmpty { - jsonCandidate = result.value?.valueForKeyPath(keyPath) + let jsonCandidate: Any? + if let keyPath = keyPath , !keyPath.isEmpty { + jsonCandidate = (result.value as AnyObject?)?.value(forKeyPath: keyPath) } else { jsonCandidate = result.value } guard let json = jsonCandidate as? UnboxableDictionary else { - return .Failure(UnboxError.InvalidData as NSError) + return .failure(UnboxError.invalidData as NSError) } do { - return .Success(try Unbox(json)) + return .success(try unbox(dictionary: json)) } catch let unboxError as UnboxError { - return .Failure(NSError(domain: "UnboxError", code: unboxError._code, userInfo: [NSLocalizedDescriptionKey: unboxError.description])) + return .failure(NSError(domain: "UnboxError", code: unboxError._code, userInfo: [NSLocalizedDescriptionKey: unboxError.description])) } catch let error as NSError { - return .Failure(error) + return .failure(error) } } } - static func UnboxArraySerializer(options: NSJSONReadingOptions, keyPath: String?) -> ResponseSerializer<[T], NSError> { - return ResponseSerializer { request, response, data, error in + static func UnboxArraySerializer(_ options: JSONSerialization.ReadingOptions, keyPath: String?) -> DataResponseSerializer<[T]> { + return DataResponseSerializer { request, response, data, error in if let error = error { - return .Failure(error) + return .failure(error) } - let JSONResponseSerializer = Request.JSONResponseSerializer(options: .AllowFragments) + let JSONResponseSerializer = DataRequest.jsonResponseSerializer(options: .allowFragments) let result = JSONResponseSerializer.serializeResponse(request, response, data, error) - let jsonCandidate: AnyObject? - if let keyPath = keyPath where !keyPath.isEmpty { - jsonCandidate = result.value?.valueForKeyPath(keyPath) + let jsonCandidate: Any? + if let keyPath = keyPath , !keyPath.isEmpty { + jsonCandidate = (result.value as AnyObject?)?.value(forKeyPath: keyPath) } else { jsonCandidate = result.value } guard let json = jsonCandidate as? [UnboxableDictionary] else { - return .Failure(UnboxError.InvalidData as NSError) + return .failure(UnboxError.invalidData as NSError) } do { - return .Success(try map(json)) + return .success(try map(json)) } catch let unboxError as UnboxError { - return .Failure(NSError(domain: "UnboxError", code: unboxError._code, userInfo: [NSLocalizedDescriptionKey: unboxError.description])) + return .failure(NSError(domain: "UnboxError", code: unboxError._code, userInfo: [NSLocalizedDescriptionKey: unboxError.description])) } catch let error as NSError { - return .Failure(error) + return .failure(error) } } } @@ -110,10 +112,10 @@ private extension Request { // MARK: - Helpers -private func map(objects: [UnboxableDictionary]) throws -> [T] { +private func map(_ objects: [UnboxableDictionary]) throws -> [T] { - return try objects.reduce([T](), combine: { container, rawValue in - let value = try Unbox(rawValue) as T + return try objects.reduce([T](), { container, rawValue in + let value = try unbox(dictionary: rawValue) as T return container + [value] }) } diff --git a/UnboxedAlamofireTests/Candy.swift b/UnboxedAlamofireTests/Candy.swift index 3d446f7..1cdea9c 100644 --- a/UnboxedAlamofireTests/Candy.swift +++ b/UnboxedAlamofireTests/Candy.swift @@ -9,13 +9,15 @@ import Unbox struct Candy { + let name: String let sweetnessLevel: Int } extension Candy: Unboxable { + init(unboxer: Unboxer) { - self.name = unboxer.unbox("name") - self.sweetnessLevel = unboxer.unbox("sweetness_level") + self.name = unboxer.unbox(key: "name") + self.sweetnessLevel = unboxer.unbox(key: "sweetness_level") } -} \ No newline at end of file +} diff --git a/UnboxedAlamofireTests/UnboxedAlamofireTests.swift b/UnboxedAlamofireTests/UnboxedAlamofireTests.swift index 13416d2..c1c7c37 100644 --- a/UnboxedAlamofireTests/UnboxedAlamofireTests.swift +++ b/UnboxedAlamofireTests/UnboxedAlamofireTests.swift @@ -12,13 +12,13 @@ import Alamofire class UnboxedAlamofireTests: XCTestCase { - private let timeout: NSTimeInterval = 5 + fileprivate let timeout: TimeInterval = 5 func test_mapObject() { let url = "https://raw.githubusercontent.com/serejahh/UnboxedAlamofire/890674cdfdcf2424f2c45ff5f4af455ccfaf7617/UnboxedAlamofireTests/fixtures/test_object.json" - let expectation = expectationWithDescription("\(url)") + let expectation = self.expectation(description: "\(url)") - Alamofire.request(.GET, url).responseObject { (response: Response) in + Alamofire.request(url, method: .get).responseObject { (response: DataResponse) in expectation.fulfill() let candy = response.result.value @@ -29,16 +29,16 @@ class UnboxedAlamofireTests: XCTestCase { XCTAssertEqual(candy?.sweetnessLevel, 80) } - waitForExpectationsWithTimeout(timeout) { error in + waitForExpectations(timeout: timeout) { error in XCTAssertNil(error, "\(error)") } } func test_mapObjectWithKeyPath() { let url = "https://raw.githubusercontent.com/serejahh/UnboxedAlamofire/890674cdfdcf2424f2c45ff5f4af455ccfaf7617/UnboxedAlamofireTests/fixtures/test_object_keypath.json" - let expectation = expectationWithDescription("\(url)") + let expectation = self.expectation(description: "\(url)") - Alamofire.request(.GET, url).responseObject(keyPath: "response") { (response: Response) in + Alamofire.request(url, method: .get).responseObject(keyPath: "response") { (response: DataResponse) in expectation.fulfill() let candy = response.result.value @@ -49,16 +49,16 @@ class UnboxedAlamofireTests: XCTestCase { XCTAssertEqual(candy?.sweetnessLevel, 80) } - waitForExpectationsWithTimeout(timeout) { error in + waitForExpectations(timeout: timeout) { error in XCTAssertNil(error, "\(error)") } } func test_mapObjectWithNestedKeyPath() { let url = "https://raw.githubusercontent.com/serejahh/UnboxedAlamofire/890674cdfdcf2424f2c45ff5f4af455ccfaf7617/UnboxedAlamofireTests/fixtures/test_object_nested_keypath.json" - let expectation = expectationWithDescription("\(url)") + let expectation = self.expectation(description: "\(url)") - Alamofire.request(.GET, url).responseObject(keyPath: "response.my") { (response: Response) in + Alamofire.request(url, method: .get).responseObject(keyPath: "response.my") { (response: DataResponse) in expectation.fulfill() let candy = response.result.value @@ -69,16 +69,16 @@ class UnboxedAlamofireTests: XCTestCase { XCTAssertEqual(candy?.sweetnessLevel, 80) } - waitForExpectationsWithTimeout(timeout) { error in + waitForExpectations(timeout: timeout) { error in XCTAssertNil(error, "\(error)") } } func test_mapArray() { let url = "https://raw.githubusercontent.com/serejahh/UnboxedAlamofire/890674cdfdcf2424f2c45ff5f4af455ccfaf7617/UnboxedAlamofireTests/fixtures/test_array.json" - let expectation = expectationWithDescription("\(url)") + let expectation = self.expectation(description: "\(url)") - Alamofire.request(.GET, url).responseArray { (response: Response<[Candy], NSError>) in + Alamofire.request(url, method: .get).responseArray { (response: DataResponse<[Candy]>) in expectation.fulfill() let candies = response.result.value @@ -88,16 +88,16 @@ class UnboxedAlamofireTests: XCTestCase { XCTAssertEqual(candies?.count, 4) } - waitForExpectationsWithTimeout(timeout) { error in + waitForExpectations(timeout: timeout) { error in XCTAssertNil(error, "\(error)") } } func test_mapArrayWithKeyPath() { let url = "https://raw.githubusercontent.com/serejahh/UnboxedAlamofire/890674cdfdcf2424f2c45ff5f4af455ccfaf7617/UnboxedAlamofireTests/fixtures/test_array_keypath.json" - let expectation = expectationWithDescription("\(url)") + let expectation = self.expectation(description: "\(url)") - Alamofire.request(.GET, url).responseArray(keyPath: "wish") { (response: Response<[Candy], NSError>) in + Alamofire.request(url, method: .get).responseArray(keyPath: "wish") { (response: DataResponse<[Candy]>) in expectation.fulfill() let candies = response.result.value @@ -107,16 +107,16 @@ class UnboxedAlamofireTests: XCTestCase { XCTAssertEqual(candies?.count, 4) } - waitForExpectationsWithTimeout(timeout) { error in + waitForExpectations(timeout: timeout) { error in XCTAssertNil(error, "\(error)") } } func test_mapArrayWithNestedKeyPath() { let url = "https://raw.githubusercontent.com/serejahh/UnboxedAlamofire/890674cdfdcf2424f2c45ff5f4af455ccfaf7617/UnboxedAlamofireTests/fixtures/test_array_nested_keypath.json" - let expectation = expectationWithDescription("\(url)") + let expectation = self.expectation(description: "\(url)") - Alamofire.request(.GET, url).responseArray(keyPath: "response.wish") { (response: Response<[Candy], NSError>) in + Alamofire.request(url, method: .get).responseArray(keyPath: "response.wish") { (response: DataResponse<[Candy]>) in expectation.fulfill() let candies = response.result.value @@ -126,7 +126,7 @@ class UnboxedAlamofireTests: XCTestCase { XCTAssertEqual(candies?.count, 4) } - waitForExpectationsWithTimeout(timeout) { error in + waitForExpectations(timeout: timeout) { error in XCTAssertNil(error, "\(error)") } }