diff options
author | Jason Wray <jason@mapbox.com> | 2018-04-12 18:59:09 -0400 |
---|---|---|
committer | Jason Wray <jason@mapbox.com> | 2018-04-16 18:42:34 -0400 |
commit | d4e597eb94a90a816fcc480fa7b6719430a20b84 (patch) | |
tree | ac098db0c1a3f35d883b8565c8bc598dc7647ad1 /platform/darwin | |
parent | 0529c018f3ea76d2aa0405c88849fe319cc1da25 (diff) | |
download | qtlocation-mapboxgl-d4e597eb94a90a816fcc480fa7b6719430a20b84.tar.gz |
[ios, macos] Convert various class methods to class properties
This improves the Swift interface while having no effect on Obj-C usage.
Diffstat (limited to 'platform/darwin')
-rw-r--r-- | platform/darwin/src/MGLAccountManager.h | 24 | ||||
-rw-r--r-- | platform/darwin/src/MGLAccountManager_Private.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLMapSnapshotter.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLNetworkConfiguration.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLRasterTileSource.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLRendererConfiguration.h | 2 | ||||
-rw-r--r-- | platform/darwin/src/MGLStyle.h | 12 | ||||
-rw-r--r-- | platform/darwin/src/MGLVectorTileSource.h | 2 | ||||
-rw-r--r-- | platform/darwin/test/MGLDocumentationExampleTests.swift | 12 |
10 files changed, 27 insertions, 35 deletions
diff --git a/platform/darwin/src/MGLAccountManager.h b/platform/darwin/src/MGLAccountManager.h index b691c4c906..436e45ca9b 100644 --- a/platform/darwin/src/MGLAccountManager.h +++ b/platform/darwin/src/MGLAccountManager.h @@ -5,7 +5,7 @@ NS_ASSUME_NONNULL_BEGIN /** - The MGLAccountManager object provides a global way to set a Mapbox API access + The `MGLAccountManager` object provides a global way to set a Mapbox API access token. */ MGL_EXPORT @@ -14,9 +14,9 @@ MGL_EXPORT #pragma mark Authorizing Access /** - Set the + The <a href="https://www.mapbox.com/help/define-access-token/">Mapbox access token</a> - to be used by all instances of MGLMapView in the current application. + used by all instances of `MGLMapView` in the current application. Mapbox-hosted vector tiles and styles require an API access token, which you can obtain from the @@ -25,24 +25,16 @@ MGL_EXPORT your Mapbox account. They also deter other developers from using your styles without your permission. - @param accessToken A Mapbox access token. Calling this method with a value of - `nil` has no effect. + Setting this property to a value of `nil` has no effect. @note You must set the access token before attempting to load any Mapbox-hosted style. Therefore, you should generally set it before creating an instance of - MGLMapView. The recommended way to set an access token is to add an entry to - your application’s Info.plist file with the key `MGLMapboxAccessToken` and - the type String. Alternatively, you may call this method from your + `MGLMapView`. The recommended way to set an access token is to add an entry + to your application’s Info.plist file with the key `MGLMapboxAccessToken` + and the type `String`. Alternatively, you may call this method from your application delegate’s `-applicationDidFinishLaunching:` method. */ -+ (void)setAccessToken:(nullable NSString *)accessToken; - -/** - Returns the - <a href="https://www.mapbox.com/help/define-access-token/">Mapbox access token</a> - in use by instances of MGLMapView in the current application. - */ -+ (nullable NSString *)accessToken; +@property (class, nullable) NSString *accessToken; + (BOOL)mapboxMetricsEnabledSettingShownInApp __attribute__((unavailable("Telemetry settings are now always shown in the ℹ️ menu."))); diff --git a/platform/darwin/src/MGLAccountManager_Private.h b/platform/darwin/src/MGLAccountManager_Private.h index 655af08f20..b68016b1a7 100644 --- a/platform/darwin/src/MGLAccountManager_Private.h +++ b/platform/darwin/src/MGLAccountManager_Private.h @@ -3,7 +3,7 @@ @interface MGLAccountManager (Private) /// Returns the shared instance of the `MGLAccountManager` class. -+ (instancetype)sharedManager; +@property (class, nonatomic, readonly) MGLAccountManager *sharedManager; /// The current global access token. @property (atomic) NSString *accessToken; diff --git a/platform/darwin/src/MGLMapSnapshotter.h b/platform/darwin/src/MGLMapSnapshotter.h index 426ab1bb00..976213c8ba 100644 --- a/platform/darwin/src/MGLMapSnapshotter.h +++ b/platform/darwin/src/MGLMapSnapshotter.h @@ -140,7 +140,7 @@ typedef void (^MGLMapSnapshotCompletionHandler)(MGLMapSnapshot* _Nullable snapsh ```swift let camera = MGLMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), fromDistance: 100, pitch: 20, heading: 0) - let options = MGLMapSnapshotOptions(styleURL: MGLStyle.satelliteStreetsStyleURL(), camera: camera, size: CGSize(width: 320, height: 480)) + let options = MGLMapSnapshotOptions(styleURL: MGLStyle.satelliteStreetsStyleURL, camera: camera, size: CGSize(width: 320, height: 480)) options.zoomLevel = 10 let snapshotter = MGLMapSnapshotter(options: options) diff --git a/platform/darwin/src/MGLNetworkConfiguration.h b/platform/darwin/src/MGLNetworkConfiguration.h index 644291ee13..2db46d78c5 100644 --- a/platform/darwin/src/MGLNetworkConfiguration.h +++ b/platform/darwin/src/MGLNetworkConfiguration.h @@ -13,7 +13,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MGLNetworkConfiguration : NSObject /// Returns the shared instance of the `MGLNetworkConfiguration` class. -+ (instancetype)sharedManager; +@property (class, nonatomic, readonly) MGLNetworkConfiguration *sharedManager; /// The current API base URL. If `nil`, the Mapbox default base API URL is in use. @property (atomic, nullable) NSURL *apiBaseURL; diff --git a/platform/darwin/src/MGLOfflineStorage.h b/platform/darwin/src/MGLOfflineStorage.h index b3c9a0ede0..a1f3e686c2 100644 --- a/platform/darwin/src/MGLOfflineStorage.h +++ b/platform/darwin/src/MGLOfflineStorage.h @@ -170,7 +170,7 @@ MGL_EXPORT /** Returns the shared offline storage object. */ -+ (instancetype)sharedOfflineStorage; +@property (class, nonatomic, readonly) MGLOfflineStorage *sharedOfflineStorage; #pragma mark - Accessing the Delegate diff --git a/platform/darwin/src/MGLRasterTileSource.h b/platform/darwin/src/MGLRasterTileSource.h index fe71e8e6ad..59b256d5e5 100644 --- a/platform/darwin/src/MGLRasterTileSource.h +++ b/platform/darwin/src/MGLRasterTileSource.h @@ -47,7 +47,7 @@ extern MGL_EXPORT const MGLTileSourceOption MGLTileSourceOptionTileSize; .maximumZoomLevel: 16, .tileSize: 512, .attributionInfos: [ - MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com")) + MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")) ] ]) mapView.style?.addSource(source) diff --git a/platform/darwin/src/MGLRendererConfiguration.h b/platform/darwin/src/MGLRendererConfiguration.h index 31aad0a742..34c8e9628b 100644 --- a/platform/darwin/src/MGLRendererConfiguration.h +++ b/platform/darwin/src/MGLRendererConfiguration.h @@ -11,7 +11,7 @@ NS_ASSUME_NONNULL_BEGIN @interface MGLRendererConfiguration : NSObject /** Returns an instance of the current renderer configuration. */ -+ (instancetype)currentConfiguration; +@property (class, nonatomic, readonly) MGLRendererConfiguration *currentConfiguration; /** The file source to use. Defaults to `mbgl::DefaultFileSource` */ @property (nonatomic, readonly) mbgl::DefaultFileSource *fileSource; diff --git a/platform/darwin/src/MGLStyle.h b/platform/darwin/src/MGLStyle.h index 762029aa58..f402acd36e 100644 --- a/platform/darwin/src/MGLStyle.h +++ b/platform/darwin/src/MGLStyle.h @@ -68,7 +68,7 @@ MGL_EXPORT `-streetsStyleURLWithVersion:` method instead. Such details may change significantly from version to version. */ -+ (NSURL *)streetsStyleURL; +@property (class, nonatomic, readonly) NSURL *streetsStyleURL; /** Returns the URL to the given version of the @@ -98,7 +98,7 @@ MGL_EXPORT `-outdoorsStyleURLWithVersion:` method instead. Such details may change significantly from version to version. */ -+ (NSURL *)outdoorsStyleURL; +@property (class, nonatomic, readonly) NSURL *outdoorsStyleURL; /** Returns the URL to the given version of the @@ -122,7 +122,7 @@ MGL_EXPORT `-lightStyleURLWithVersion:` method instead. Such details may change significantly from version to version. */ -+ (NSURL *)lightStyleURL; +@property (class, nonatomic, readonly) NSURL *lightStyleURL; /** Returns the URL to the given version of the @@ -147,7 +147,7 @@ MGL_EXPORT `-darkStyleURLWithVersion:` method instead. Such details may change significantly from version to version. */ -+ (NSURL *)darkStyleURL; +@property (class, nonatomic, readonly) NSURL *darkStyleURL; /** Returns the URL to the given version of the @@ -172,7 +172,7 @@ MGL_EXPORT `-satelliteStyleURLWithVersion:` method instead. Such details may change significantly from version to version. */ -+ (NSURL *)satelliteStyleURL; +@property (class, nonatomic, readonly) NSURL *satelliteStyleURL; /** Returns the URL to the given version of the @@ -203,7 +203,7 @@ MGL_EXPORT `-satelliteStreetsStyleURLWithVersion:` method instead. Such details may change significantly from version to version. */ -+ (NSURL *)satelliteStreetsStyleURL; +@property (class, nonatomic, readonly) NSURL *satelliteStreetsStyleURL; /** Returns the URL to the given version of the diff --git a/platform/darwin/src/MGLVectorTileSource.h b/platform/darwin/src/MGLVectorTileSource.h index 51f19a231f..790c9d4d42 100644 --- a/platform/darwin/src/MGLVectorTileSource.h +++ b/platform/darwin/src/MGLVectorTileSource.h @@ -48,7 +48,7 @@ NS_ASSUME_NONNULL_BEGIN .minimumZoomLevel: 9, .maximumZoomLevel: 16, .attributionInfos: [ - MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com")) + MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")) ] ]) mapView.style?.addSource(source) diff --git a/platform/darwin/test/MGLDocumentationExampleTests.swift b/platform/darwin/test/MGLDocumentationExampleTests.swift index 92f5162aab..9edb33a078 100644 --- a/platform/darwin/test/MGLDocumentationExampleTests.swift +++ b/platform/darwin/test/MGLDocumentationExampleTests.swift @@ -80,7 +80,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { .maximumZoomLevel: 16, .tileSize: 512, .attributionInfos: [ - MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com")) + MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")) ] ]) mapView.style?.addSource(source) @@ -115,7 +115,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { .minimumZoomLevel: 9, .maximumZoomLevel: 16, .attributionInfos: [ - MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com")) + MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")) ] ]) mapView.style?.addSource(source) @@ -280,7 +280,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { .maximumZoomLevel: 16, .tileSize: 512, .attributionInfos: [ - MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com")) + MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")) ] ]) mapView.style?.addSource(source) @@ -300,7 +300,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { .maximumZoomLevel: 16, .tileSize: 256, .attributionInfos: [ - MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "http://mapbox.com")) + MGLAttributionInfo(title: NSAttributedString(string: "© Mapbox"), url: URL(string: "https://mapbox.com")) ] ]) mapView.style?.addSource(source) @@ -370,7 +370,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { #endif class MGLStyle { - static func satelliteStreetsStyleURL() -> URL { + static var satelliteStreetsStyleURL: URL { return MGLDocumentationExampleTests.styleURL } } @@ -378,7 +378,7 @@ class MGLDocumentationExampleTests: XCTestCase, MGLMapViewDelegate { //#-example-code let camera = MGLMapCamera(lookingAtCenter: CLLocationCoordinate2D(latitude: 37.7184, longitude: -122.4365), fromDistance: 100, pitch: 20, heading: 0) - let options = MGLMapSnapshotOptions(styleURL: MGLStyle.satelliteStreetsStyleURL(), camera: camera, size: CGSize(width: 320, height: 480)) + let options = MGLMapSnapshotOptions(styleURL: MGLStyle.satelliteStreetsStyleURL, camera: camera, size: CGSize(width: 320, height: 480)) options.zoomLevel = 10 let snapshotter = MGLMapSnapshotter(options: options) |