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

Update to Swift 4.2, Adopt Hasher #164

Merged
merged 11 commits into from
Nov 8, 2018
2 changes: 1 addition & 1 deletion Geocoder Example/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import UIKit
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
hyerra marked this conversation as resolved.
Show resolved Hide resolved
window = UIWindow(frame: UIScreen.main.bounds)
window!.rootViewController = ViewController(nibName: nil, bundle: nil)
window!.makeKeyAndVisible()
Expand Down
24 changes: 9 additions & 15 deletions MapboxGeocoder.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -738,19 +738,19 @@
};
DD342B4F19A140EE00219F77 = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0910;
LastSwiftMigration = 1000;
};
DDC2470319A1C3B40054B0C0 = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0910;
LastSwiftMigration = 1000;
};
DDC2472919A1C60E0054B0C0 = {
CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0800;
};
DDF1E8491BD6F7BA00C40C78 = {
CreatedOnToolsVersion = 7.0.1;
LastSwiftMigration = 0920;
LastSwiftMigration = 1000;
};
};
};
Expand Down Expand Up @@ -1519,8 +1519,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Geocoder.Swift;
PRODUCT_NAME = "Geocoder (Swift)";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1539,8 +1538,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.Geocoder.Swift;
PRODUCT_NAME = "Geocoder (Swift)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -1565,8 +1563,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand All @@ -1589,8 +1586,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
VERSIONING_SYSTEM = "apple-generic";
VERSION_INFO_PREFIX = "";
};
Expand Down Expand Up @@ -1645,8 +1641,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -1666,8 +1661,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGeocoderTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_SWIFT3_OBJC_INFERENCE = Off;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
6 changes: 4 additions & 2 deletions MapboxGeocoder/MBPlacemark.swift
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,10 @@ open class Placemark: NSObject, Codable {
}
}

@objc open override var hashValue: Int {
return identifier.hashValue
open override var hash: Int {
hyerra marked this conversation as resolved.
Show resolved Hide resolved
hyerra marked this conversation as resolved.
Show resolved Hide resolved
var hasher = Hasher()
hasher.combine(identifier.hashValue)
return hasher.finalize()
}

@objc open override func isEqual(_ object: Any?) -> Bool {
Expand Down
10 changes: 7 additions & 3 deletions MapboxGeocoder/MBRectangularRegion.swift
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,13 @@ open class RectangularRegion: CLRegion, Codable {
try container.encode(northEast, forKey: .northEast)
}

@objc open override var hashValue: Int {
return (southWest.latitude.hashValue + southWest.longitude.hashValue
+ northEast.latitude.hashValue + northEast.longitude.hashValue)
open override var hash: Int {
var hasher = Hasher()
hyerra marked this conversation as resolved.
Show resolved Hide resolved
hasher.combine(southWest.latitude.hashValue)
hasher.combine(southWest.longitude.hashValue)
hasher.combine(northEast.latitude.hashValue)
hasher.combine(northEast.longitude.hashValue)
return hasher.finalize()
}

@objc open override func isEqual(_ object: Any?) -> Bool {
Expand Down