diff --git a/Demo.xcodeproj/project.pbxproj b/Demo.xcodeproj/project.pbxproj index 08fc766..01cefc0 100755 --- a/Demo.xcodeproj/project.pbxproj +++ b/Demo.xcodeproj/project.pbxproj @@ -557,27 +557,32 @@ CreatedOnToolsVersion = 7.3.1; DevelopmentTeam = C6K65RDJHL; DevelopmentTeamName = "Elvis Nunez (Personal Team)"; + LastSwiftMigration = 0800; ProvisioningStyle = Automatic; }; 14638CF91CC6459A002B9433 = { CreatedOnToolsVersion = 7.3; DevelopmentTeam = C6K65RDJHL; DevelopmentTeamName = "Elvis Nunez (Personal Team)"; + LastSwiftMigration = 0800; }; 14638D111CC646F9002B9433 = { CreatedOnToolsVersion = 7.3; DevelopmentTeam = C6K65RDJHL; DevelopmentTeamName = "Elvis Nunez (Personal Team)"; + LastSwiftMigration = 0800; }; 14638D271CC64747002B9433 = { CreatedOnToolsVersion = 7.3; DevelopmentTeam = C6K65RDJHL; DevelopmentTeamName = "Elvis Nunez (Personal Team)"; + LastSwiftMigration = 0800; }; 14638D3D1CC647E4002B9433 = { CreatedOnToolsVersion = 7.3; DevelopmentTeam = C6K65RDJHL; DevelopmentTeamName = "Elvis Nunez (Personal Team)"; + LastSwiftMigration = 0800; ProvisioningStyle = Automatic; }; 146D72AB1AB782920058798C = { @@ -589,6 +594,7 @@ 44B5D3881D19B9E5004378B9 = { DevelopmentTeam = C6K65RDJHL; DevelopmentTeamName = "Elvis Nunez (Personal Team)"; + LastSwiftMigration = 0800; }; }; }; @@ -878,6 +884,7 @@ SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Resources/Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; }; name = Debug; }; @@ -898,6 +905,7 @@ SDKROOT = macosx; SWIFT_OBJC_BRIDGING_HEADER = "Tests/Resources/Bridging-Header.h"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; }; name = Release; }; @@ -920,6 +928,7 @@ PRODUCT_NAME = Networking; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -945,6 +954,7 @@ PRODUCT_NAME = Networking; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -971,6 +981,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -998,6 +1009,7 @@ SDKROOT = watchos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 4; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -1024,6 +1036,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -1050,6 +1063,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; VERSIONING_SYSTEM = "apple-generic"; @@ -1080,6 +1094,7 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + SWIFT_VERSION = 3.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; @@ -1108,6 +1123,7 @@ SDKROOT = macosx; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_VERSION = 3.0; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; }; diff --git a/Sources/Networking+Image.swift b/Sources/Networking+Image.swift index 5966546..73968fb 100644 --- a/Sources/Networking+Image.swift +++ b/Sources/Networking+Image.swift @@ -9,7 +9,7 @@ public extension Networking { */ public func imageFromCache(_ path: String, cacheName: String? = nil, completion: (image: NetworkingImage?) -> Void) { self.objectFromCache(path, cacheName: cacheName, responseType: .image) { object in - TestCheck.testBlock(disabled: self.disableTestingMode) { + TestCheck.testBlock(self.disableTestingMode) { completion(image: object as? NetworkingImage) } } @@ -23,7 +23,7 @@ public extension Networking { */ public func downloadImage(_ path: String, cacheName: String? = nil, completion: (image: NetworkingImage?, error: NSError?) -> Void) { self.request(.GET, path: path, cacheName: cacheName, parameterType: nil, parameters: nil, parts: nil, responseType: .image) { response, _, error in - TestCheck.testBlock(disabled: self.disableTestingMode) { + TestCheck.testBlock(self.disableTestingMode) { completion(image: response as? NetworkingImage, error: error) } } diff --git a/Sources/Networking.swift b/Sources/Networking.swift index a52879e..f37911a 100644 --- a/Sources/Networking.swift +++ b/Sources/Networking.swift @@ -73,7 +73,7 @@ public class Networking { */ case custom(String) - func contentType(boundary: String) -> String { + func contentType(_ boundary: String) -> String { switch self { case .json: return "application/json" @@ -152,7 +152,7 @@ public class Networking { - parameter username: The username to be used. - parameter password: The password to be used. */ - public func authenticate(username: String, password: String) { + public func authenticate(_ username: String, password: String) { let credentialsString = "\(username):\(password)" if let credentialsData = credentialsString.data(using: String.Encoding.utf8) { let base64Credentials = credentialsData.base64EncodedString([]) @@ -169,7 +169,7 @@ public class Networking { Authenticates using a Bearer token, sets the Authorization header to "Bearer \(token)". - parameter token: The token to be used. */ - public func authenticate(token: String) { + public func authenticate(_ token: String) { self.token = token } @@ -178,7 +178,7 @@ public class Networking { - parameter authorizationHeaderKey: Sets this value as the key for the HTTP `Authorization` header - parameter authorizationHeaderValue: Sets this value to the HTTP `Authorization` header or to the `headerKey` if you provided that. */ - public func authenticate(headerKey: String = "Authorization", headerValue: String) { + public func authenticate(_ headerKey: String = "Authorization", headerValue: String) { self.authorizationHeaderKey = headerKey self.authorizationHeaderValue = headerValue } @@ -278,7 +278,7 @@ public class Networking { sessionTask.cancel() } - TestCheck.testBlock(disabled: self.disableTestingMode) { + TestCheck.testBlock(self.disableTestingMode) { completion?() } } @@ -303,7 +303,7 @@ public class Networking { */ public func dataFromCache(_ path: String, cacheName: String? = nil, completion: (data: Data?) -> Void) { self.objectFromCache(path, cacheName: cacheName, responseType: .data) { object in - TestCheck.testBlock(disabled: self.disableTestingMode) { + TestCheck.testBlock(self.disableTestingMode) { completion(data: object as? Data) } } @@ -421,7 +421,7 @@ extension Networking { } } - TestCheck.testBlock(disabled: self.disableTestingMode) { + TestCheck.testBlock(self.disableTestingMode) { completion(response: returnedResponse, headers: headers, error: returnedError) } } @@ -429,7 +429,7 @@ extension Networking { case .data, .image: self.objectFromCache(path, cacheName: cacheName, responseType: responseType) { object in if let object = object { - TestCheck.testBlock(disabled: self.disableTestingMode) { + TestCheck.testBlock(self.disableTestingMode) { completion(response: object, headers: [String : AnyObject](), error: nil) } } else { @@ -454,7 +454,7 @@ extension Networking { break } } - TestCheck.testBlock(disabled: self.disableTestingMode) { + TestCheck.testBlock(self.disableTestingMode) { completion(response: returnedResponse, headers: [String : AnyObject](), error: error) } } @@ -474,7 +474,7 @@ extension Networking { request.httpMethod = requestType.rawValue if let parameterType = parameterType { - request.addValue(parameterType.contentType(boundary: self.boundary), forHTTPHeaderField: "Content-Type") + request.addValue(parameterType.contentType(self.boundary), forHTTPHeaderField: "Content-Type") } if let accept = responseType.accept { diff --git a/Sources/NetworkingImage.swift b/Sources/NetworkingImage.swift index b9a4bd3..6e0f5ce 100644 --- a/Sources/NetworkingImage.swift +++ b/Sources/NetworkingImage.swift @@ -22,7 +22,7 @@ extension NetworkingImage { } #if os(OSX) - func data(type: NSBitmapImageFileType) -> Data? { + func data(_ type: NSBitmapImageFileType) -> Data? { let imageData = self.tiffRepresentation! let bitmapImageRep = NSBitmapImageRep(data: imageData)! let data = bitmapImageRep.representation(using: type, properties: [String : AnyObject]()) @@ -32,7 +32,7 @@ extension NetworkingImage { func pngData() -> Data? { #if os(OSX) - return self.data(type: .PNG) + return self.data(.PNG) #else return UIImagePNGRepresentation(self) #endif @@ -40,7 +40,7 @@ extension NetworkingImage { func jpgData() -> Data? { #if os(OSX) - return self.data(type: .JPEG) + return self.data(.JPEG) #else return UIImageJPEGRepresentation(self, 1) #endif diff --git a/Sources/TestCheck.swift b/Sources/TestCheck.swift index 11c1930..65b8591 100644 --- a/Sources/TestCheck.swift +++ b/Sources/TestCheck.swift @@ -29,7 +29,7 @@ struct TestCheck { /** If it's in a unit testing target then it will return in the current thread, otherwise it will return in the main thread. */ - static func testBlock(disabled: Bool, block: (Void) -> Void) { + static func testBlock(_ disabled: Bool, block: (Void) -> Void) { if TestCheck.isTesting && disabled == false { block() } else {