Skip to content

Commit

Permalink
Updates for Swift 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
Erik Sargent committed Mar 28, 2017
1 parent ffee87b commit d8ff579
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 24 deletions.
6 changes: 3 additions & 3 deletions Example/LKAPI.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0720;
LastUpgradeCheck = 0800;
LastUpgradeCheck = 0830;
ORGANIZATIONNAME = CocoaPods;
TargetAttributes = {
607FACE41AFB9204008FA782 = {
Expand Down Expand Up @@ -320,7 +320,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = 00E2D8A65F27E0001F1BCE5C /* Pods-LKAPI_Tests.debug.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand All @@ -341,7 +341,7 @@
isa = XCBuildConfiguration;
baseConfigurationReference = DBDD8842462905F99CB51A11 /* Pods-LKAPI_Tests.release.xcconfig */;
buildSettings = {
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = "$(inherited)";
ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES;
FRAMEWORK_SEARCH_PATHS = (
"$(SDKROOT)/Developer/Library/Frameworks",
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0800"
LastUpgradeVersion = "0830"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
14 changes: 7 additions & 7 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
PODS:
- Alamofire (4.0.0)
- LKAPI (1.2.0):
- Alamofire (4.4.0)
- LKAPI (1.2.2):
- Alamofire

DEPENDENCIES:
Expand All @@ -9,12 +9,12 @@ DEPENDENCIES:

EXTERNAL SOURCES:
LKAPI:
:path: ../
:path: "../"

SPEC CHECKSUMS:
Alamofire: fef59f00388f267e52d9b432aa5d93dc97190f14
LKAPI: 0a440e5518f439c21b0f4ca9a81f98a012c349cd
Alamofire: dc44b1600b800eb63da6a19039a0083d62a6a62d
LKAPI: bf6e5af601ad854c127412c3969f5803ef25157e

PODFILE CHECKSUM: 0293954057b7f5af945b7e06279b1d86a8c755f1
PODFILE CHECKSUM: '0293954057b7f5af945b7e06279b1d86a8c755f1'

COCOAPODS: 1.1.0.rc.2
COCOAPODS: 1.2.0
4 changes: 2 additions & 2 deletions Example/Tests/APITests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class APITests: XCTestCase {
XCTAssertEqual(some, "data")
}
else {
print(data)
print(data ?? "Data is nil")
XCTFail("Unable to cast data")
}

Expand Down Expand Up @@ -108,7 +108,7 @@ class APITests: XCTestCase {
XCTAssertEqual(test, "data")
}
else {
print(data)
print(data ?? "Data is nil")
XCTFail("Unable to cast data")
}
}) { error in
Expand Down
20 changes: 9 additions & 11 deletions Pod/Classes/API.swift
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ extension ModelType {
public extension Dictionary where Key: ExpressibleByStringLiteral, Value: Any {
///Try to parse an object out of the dictionary, and return the fallback if it fails
public func parse<T>(_ key: String) -> T? {
if let dict = (self as? Any) as? ModelDict, let object = dict[key] as? T {
if let dict = self as? ModelDict, let object = dict[key] as? T {
return object
}

Expand All @@ -55,7 +55,7 @@ public extension Dictionary where Key: ExpressibleByStringLiteral, Value: Any {

///Try to parse an object out of the dictionary, and return the fallback if it fails
public func parse<T>(_ key: String, or fallback: T) -> T {
if let dict = (self as? Any) as? ModelDict, let object = dict[key] as? T {
if let dict = self as? ModelDict, let object = dict[key] as? T {
return object
}

Expand All @@ -64,7 +64,7 @@ public extension Dictionary where Key: ExpressibleByStringLiteral, Value: Any {

///Parse the field as a Parseable
public func parse<T>(_ key: String) -> T? where T: Parseable {
if let dict = (self as? Any) as? ModelDict, let object = dict[key] {
if let dict = self as? ModelDict, let object = dict[key] {
return T.parse(object) as? T
}

Expand All @@ -73,7 +73,7 @@ public extension Dictionary where Key: ExpressibleByStringLiteral, Value: Any {

///Parse the dictionary as a ModelType
public func parse<T>() -> T? where T: ModelType {
if let dict = (self as? Any) as? ModelDict {
if let dict = self as? ModelDict {
return T(data: dict)
}

Expand Down Expand Up @@ -240,7 +240,7 @@ open class API {
}
}

print("Status code \(response.response?.statusCode). message: \(message)\ndata: \(responseData)\n\n")
print("Status code \(response.response?.statusCode ?? -1). message: \(message)\ndata: \(responseData)\n\n")

failure?(Failure(error: error, message: message, code: response.response?.statusCode, data: responseData))
}
Expand All @@ -258,13 +258,11 @@ open class API {
///Mocked data for testing requests
public extension API {
///Load in and parse the stored JSON file
public class func mockedDataObject(_ path: String) -> AnyObject? {
public class func mockedDataObject(_ path: String) -> Any? {
do {
if let dataPath = Bundle.main.path(forResource: path, ofType: "json"),
let data = try? Data(contentsOf: URL(fileURLWithPath: dataPath)),
let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments) as? AnyObject {

return json
if let dataPath = Bundle.main.path(forResource: path, ofType: "json"), let data = try? Data(contentsOf: URL(fileURLWithPath: dataPath)) {
let json = try JSONSerialization.jsonObject(with: data, options: .allowFragments)
return json
}
else {
print("❌ Unable to load file: \(path)")
Expand Down

0 comments on commit d8ff579

Please sign in to comment.