Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubdate to Swift 5.0 #1066

Open
wants to merge 1 commit 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
16 changes: 6 additions & 10 deletions ObjectMapper.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -728,11 +728,11 @@
};
6AAC8F7519F03C2900E7A677 = {
CreatedOnToolsVersion = 6.0.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
6AAC8F8019F03C2900E7A677 = {
CreatedOnToolsVersion = 6.0.1;
LastSwiftMigration = 0900;
LastSwiftMigration = 1020;
};
CD1602FE1AC023D5000CD69A = {
CreatedOnToolsVersion = 6.2;
Expand Down Expand Up @@ -1363,8 +1363,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.tristanhimmelman.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(PROJECT_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand All @@ -1385,8 +1384,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "com.tristanhimmelman.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(PROJECT_NAME)";
SKIP_INSTALL = YES;
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TVOS_DEPLOYMENT_TARGET = 9.0;
WATCHOS_DEPLOYMENT_TARGET = 2.0;
};
Expand All @@ -1404,8 +1402,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.heart.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Debug;
};
Expand All @@ -1417,8 +1414,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "com.heart.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Sources/ISO8601DateTransform.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import Foundation

public extension DateFormatter {
convenience init(withFormat format : String, locale : String) {
@objc convenience init(withFormat format : String, locale : String) {
self.init()
self.locale = Locale(identifier: locale)
dateFormat = format
Expand Down
2 changes: 1 addition & 1 deletion Sources/ImmutableMappable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ public extension Mapper where N: ImmutableMappable {
#if swift(>=4.1)
return try JSONArray.compactMap(mapOrFail)
#else
return try JSONArray.flatMap(mapOrFail)
return try JSONArray.compactMap(mapOrFail)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please just remove else statement if it is necessary because now if and else blocks has same actions.

#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/Map.swift
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ public final class Map {
#if swift(>=4.1)
return v.compactMap{ Float($0) } as? T
#else
return v.flatMap{ Float($0) } as? T
return v.compactMap{ Float($0) } as? T
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.

Please just remove else statement if it is necessary because now if and else blocks has same actions.

#endif
}
} else if value == nil && T.self == [String:Float].self {
Expand Down
4 changes: 2 additions & 2 deletions Sources/Mapper.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ public final class Mapper<N: BaseMappable> {
#if swift(>=4.1)
let result = JSONArray.compactMap(map)
#else
let result = JSONArray.flatMap(map)
let result = JSONArray.compactMap(map)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.
Please just remove else statement if it is necessary because now if and else blocks has same actions.

#endif
return result
}
Expand Down Expand Up @@ -433,7 +433,7 @@ extension Mapper where N: Hashable {
#if swift(>=4.1)
return Set(JSONArray.compactMap(map))
#else
return Set(JSONArray.flatMap(map))
return Set(JSONArray.compactMap(map))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment as above.
Please just remove else statement if it is necessary because now if and else blocks has same actions.

#endif
}

Expand Down
2 changes: 1 addition & 1 deletion Sources/ToJSON.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ private func setValue(_ value: Any, forKeyPathComponents components: ArraySlice<

let headAsString = String(head)
if components.count == 1 {
dictionary[headAsString] = value
dictionary[headAsString] = value
} else {
var child = dictionary[headAsString] as? [String : Any] ?? [:]

Expand Down
12 changes: 6 additions & 6 deletions Sources/TransformOperators.swift
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ public func <- <Transform: TransformType>(left: inout [[Transform.Object]], righ
fromJSONArrayWithTransform(values as Any?, transform: transform)
}
#else
let transformed2DArray = original2DArray.flatMap { values in
let transformed2DArray = original2DArray.compactMap { values in
fromJSONArrayWithTransform(values as Any?, transform: transform)
}
#endif
Expand All @@ -522,7 +522,7 @@ public func >>> <Transform: TransformType>(left: [[Transform.Object]], right: (M
toJSONArrayWithTransform(values, transform: transform)
}
#else
let transformed2DArray = left.flatMap { values in
let transformed2DArray = left.compactMap { values in
toJSONArrayWithTransform(values, transform: transform)
}
#endif
Expand All @@ -543,7 +543,7 @@ public func <- <Transform: TransformType>(left: inout [[Transform.Object]]?, rig
fromJSONArrayWithTransform(values as Any?, transform: transform)
}
#else
let transformed2DArray = original2DArray.flatMap { values in
let transformed2DArray = original2DArray.compactMap { values in
fromJSONArrayWithTransform(values as Any?, transform: transform)
}
#endif
Expand All @@ -561,7 +561,7 @@ public func >>> <Transform: TransformType>(left: [[Transform.Object]]?, right: (
toJSONArrayWithTransform(values, transform: transform)
}
#else
let transformed2DArray = left?.flatMap { values in
let transformed2DArray = left?.compactMap { values in
toJSONArrayWithTransform(values, transform: transform)
}
#endif
Expand Down Expand Up @@ -671,7 +671,7 @@ private func fromJSONArrayWithTransform<Transform: TransformType>(_ input: Any?,
return transform.transformFromJSON(value)
}
#else
return values.flatMap { value in
return values.compactMap { value in
return transform.transformFromJSON(value)
}
#endif
Expand All @@ -696,7 +696,7 @@ private func toJSONArrayWithTransform<Transform: TransformType>(_ input: [Transf
return transform.transformToJSON(value)
}
#else
return input?.flatMap { value in
return input?.compactMap { value in
return transform.transformToJSON(value)
}
#endif
Expand Down