From 0fb1920376258c24802ddfb0b9833dc7da5ce000 Mon Sep 17 00:00:00 2001 From: Fredrik Karlsson Date: Tue, 18 Sep 2018 12:57:48 +0200 Subject: [PATCH] Rename delegate method to conform to Swift API design guidelines --- CHANGELOG.md | 4 ++++ MapboxNavigation/CarPlayMapViewController.swift | 2 +- MapboxNavigation/CarPlayNavigationViewController.swift | 2 +- MapboxNavigation/NavigationViewController.swift | 2 +- MapboxNavigation/StyleManager.swift | 9 +++++---- .../NavigationViewControllerTests.swift | 2 +- MapboxNavigationTests/StyleManagerTests.swift | 2 +- 7 files changed, 14 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9a1d5a15b88..4ab7a13dc6f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Changes to the Mapbox Navigation SDK for iOS +## master + +`StyleManagerDelegate.locationFor(styleManager:)` has been renamed to `StyleManagerDelegate.location(for:)` ([#1724](https://github.com/mapbox/mapbox-navigation-ios/pull/1724)) + ## v0.21.0 (September 17, 2018) ### User interface diff --git a/MapboxNavigation/CarPlayMapViewController.swift b/MapboxNavigation/CarPlayMapViewController.swift index 457b58282b0..90def749fae 100644 --- a/MapboxNavigation/CarPlayMapViewController.swift +++ b/MapboxNavigation/CarPlayMapViewController.swift @@ -122,7 +122,7 @@ class CarPlayMapViewController: UIViewController, MGLMapViewDelegate { @available(iOS 12.0, *) extension CarPlayMapViewController: StyleManagerDelegate { - func locationFor(styleManager: StyleManager) -> CLLocation? { + func location(for styleManager: StyleManager) -> CLLocation? { return mapView.userLocationForCourseTracking ?? mapView.userLocation?.location ?? coarseLocationManager.location } diff --git a/MapboxNavigation/CarPlayNavigationViewController.swift b/MapboxNavigation/CarPlayNavigationViewController.swift index be0fde9b01e..0df5ba13805 100644 --- a/MapboxNavigation/CarPlayNavigationViewController.swift +++ b/MapboxNavigation/CarPlayNavigationViewController.swift @@ -376,7 +376,7 @@ public class CarPlayNavigationViewController: UIViewController, MGLMapViewDelega @available(iOS 12.0, *) extension CarPlayNavigationViewController: StyleManagerDelegate { - public func locationFor(styleManager: StyleManager) -> CLLocation? { + public func location(for styleManager: StyleManager) -> CLLocation? { return routeController.locationManager.location } diff --git a/MapboxNavigation/NavigationViewController.swift b/MapboxNavigation/NavigationViewController.swift index 0b309c024e2..8df6f71580c 100644 --- a/MapboxNavigation/NavigationViewController.swift +++ b/MapboxNavigation/NavigationViewController.swift @@ -685,7 +685,7 @@ extension NavigationViewController: TunnelIntersectionManagerDelegate { extension NavigationViewController: StyleManagerDelegate { - public func locationFor(styleManager: StyleManager) -> CLLocation? { + public func location(for styleManager: StyleManager) -> CLLocation? { if let location = routeController.location { return location } else if let firstCoord = routeController.routeProgress.route.coordinates?.first { diff --git a/MapboxNavigation/StyleManager.swift b/MapboxNavigation/StyleManager.swift index b9b282ec0d0..562ce7347d8 100644 --- a/MapboxNavigation/StyleManager.swift +++ b/MapboxNavigation/StyleManager.swift @@ -9,7 +9,8 @@ public protocol StyleManagerDelegate: NSObjectProtocol { /** Asks the delegate for a location to use when calculating sunset and sunrise. */ - @objc func locationFor(styleManager: StyleManager) -> CLLocation? + @objc(locationForStyleManager:) + func location(for styleManager: StyleManager) -> CLLocation? /** Informs the delegate that a style was applied. @@ -95,7 +96,7 @@ open class StyleManager: NSObject { NSObject.cancelPreviousPerformRequests(withTarget: self, selector: #selector(timeOfDayChanged), object: nil) guard automaticallyAdjustsStyleForTimeOfDay && styles.count > 1 else { return } - guard let location = delegate?.locationFor(styleManager: self) else { return } + guard let location = delegate?.location(for:self) else { return } guard let solar = Solar(date: date, coordinate: location.coordinate), let sunrise = solar.sunrise, @@ -137,7 +138,7 @@ open class StyleManager: NSObject { } func applyStyle() { - guard let location = delegate?.locationFor(styleManager: self) else { + guard let location = delegate?.location(for: self) else { // We can't calculate sunset or sunrise w/o a location so just apply the first style if let style = styles.first, currentStyleType != style.styleType { currentStyleType = style.styleType @@ -172,7 +173,7 @@ open class StyleManager: NSObject { } func forceRefreshAppearanceIfNeeded() { - guard let location = delegate?.locationFor(styleManager: self) else { return } + guard let location = delegate?.location(for: self) else { return } let styleTypeForLocation = styleType(for: location) diff --git a/MapboxNavigationTests/NavigationViewControllerTests.swift b/MapboxNavigationTests/NavigationViewControllerTests.swift index 8fd9786c7c3..8790b990247 100644 --- a/MapboxNavigationTests/NavigationViewControllerTests.swift +++ b/MapboxNavigationTests/NavigationViewControllerTests.swift @@ -215,7 +215,7 @@ class NavigationViewControllerTests: XCTestCase { } extension NavigationViewControllerTests: NavigationViewControllerDelegate, StyleManagerDelegate { - func locationFor(styleManager: StyleManager) -> CLLocation? { + func location(for styleManager: StyleManager) -> CLLocation? { return dependencies.poi.first! } diff --git a/MapboxNavigationTests/StyleManagerTests.swift b/MapboxNavigationTests/StyleManagerTests.swift index 72009ee2445..49c62d0be68 100644 --- a/MapboxNavigationTests/StyleManagerTests.swift +++ b/MapboxNavigationTests/StyleManagerTests.swift @@ -129,7 +129,7 @@ extension StyleManagerTests: StyleManagerDelegate { func styleManagerDidRefreshAppearance(_ styleManager: StyleManager) { } func styleManager(_ styleManager: StyleManager, didApply style: Style) { } - func locationFor(styleManager: StyleManager) -> CLLocation? { + func location(for styleManager: StyleManager) -> CLLocation? { return location } }