Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

Cleanup, migration and fixes #8

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions HermesNetwork.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,11 @@
TargetAttributes = {
52D6D97B1BEFF229002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1000;
};
52D6D9851BEFF229002C0205 = {
CreatedOnToolsVersion = 7.1;
LastSwiftMigration = 0800;
LastSwiftMigration = 1000;
};
52D6D9E11BEFFF6E002C0205 = {
CreatedOnToolsVersion = 7.1;
Expand Down Expand Up @@ -656,7 +656,7 @@
PRODUCT_NAME = HermesNetwork;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -678,7 +678,7 @@
PRODUCT_NAME = HermesNetwork;
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -691,7 +691,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.HermesNetwork.HermesNetwork-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -704,7 +704,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.HermesNetwork.HermesNetwork-iOS-Tests";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Sources/Extension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public extension Dictionary where Key == String, Value == Any? {
/// - Throws: throw `.dataIsNotEncodable` if data cannot be encoded
public func urlEncodedString(base: String = "") throws -> String {
guard self.count > 0 else { return "" } // nothing to encode
let items: [URLQueryItem] = self.flatMap { (key,value) in
let items: [URLQueryItem] = self.compactMap { (key,value) in
guard let v = value else { return nil } // skip item if no value is set
return URLQueryItem(name: key, value: String(describing: v))
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/ResponseProtocol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,16 @@ public class Response: ResponseProtocol {
}

public func toJSON() -> JSON {
return self.cachedJSON
return self.cachedJSON ?? JSON()
}

public func toString(_ encoding: String.Encoding? = nil) -> String? {
guard let d = self.data else { return nil }
return String(data: d, encoding: encoding ?? .utf8)
}

private lazy var cachedJSON: JSON = {
return JSON(data: self.data ?? Data())
private lazy var cachedJSON: JSON? = {
return try? JSON(data: self.data ?? Data())
}()

}