diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-10-22 15:12:35 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-11-02 12:40:40 -0700 |
commit | c2e37f062be6848a73eb5659f253775aa0abfe02 (patch) | |
tree | e3fafb0cc1e9618249b98ff76d67077c416be19c | |
parent | 14663a5185ef25c6ea9592f6e9c425a3890f4c92 (diff) | |
download | qtlocation-mapboxgl-c2e37f062be6848a73eb5659f253775aa0abfe02.tar.gz |
[ios, macos] Adopted string enumerations
Notification names and user info keys posted by MGLOfflineStorage, as well as MGLErrorDomain, are instances of string enumerations for ease of use in Swift. Added some shims for projects built with Xcode 7.x.
Fixes #6791.
-rw-r--r-- | platform/darwin/src/MGLGeoJSONSource.h | 23 | ||||
-rw-r--r-- | platform/darwin/src/MGLOfflineStorage.h | 19 | ||||
-rw-r--r-- | platform/darwin/src/MGLTypes.h | 8 | ||||
-rw-r--r-- | platform/ios/CHANGELOG.md | 1 | ||||
-rw-r--r-- | platform/macos/CHANGELOG.md | 1 |
5 files changed, 35 insertions, 17 deletions
diff --git a/platform/darwin/src/MGLGeoJSONSource.h b/platform/darwin/src/MGLGeoJSONSource.h index d0c1e0dc67..67c6301bfc 100644 --- a/platform/darwin/src/MGLGeoJSONSource.h +++ b/platform/darwin/src/MGLGeoJSONSource.h @@ -7,18 +7,23 @@ NS_ASSUME_NONNULL_BEGIN @protocol MGLFeature; /** + Options for `MGLGeoJSONSource` objects. + */ +typedef NSString *MGLGeoJSONSourceOption NS_STRING_ENUM; + +/** An `NSNumber` object containing a Boolean enabling or disabling clustering. If the `features` property contains point features, setting this option to `YES` clusters the points by radius into groups. The default value is `NO`. */ -extern NSString * const MGLGeoJSONClusterOption; +extern MGLGeoJSONSourceOption const MGLGeoJSONClusterOption; /** An `NSNumber` object containing an integer; specifies the radius of each cluster if clustering is enabled. A value of 512 produces a radius equal to the width of a tile. The default value is 50. */ -extern NSString * const MGLGeoJSONClusterRadiusOption; +extern MGLGeoJSONSourceOption const MGLGeoJSONClusterRadiusOption; /** An `NSNumber` object containing an integer; specifies the maximum zoom level at @@ -26,14 +31,14 @@ extern NSString * const MGLGeoJSONClusterRadiusOption; less than the value of `MGLGeoJSONMaximumZoomLevelOption` so that, at the maximum zoom level, the features are not clustered. */ -extern NSString * const MGLGeoJSONClusterMaximumZoomLevelOption; +extern MGLGeoJSONSourceOption const MGLGeoJSONClusterMaximumZoomLevelOption; /** An `NSNumber` object containing an integer; specifies the maximum zoom level at which to create vector tiles. A greater value produces greater detail at high zoom levels. The default value is 18. */ -extern NSString * const MGLGeoJSONMaximumZoomLevelOption; +extern MGLGeoJSONSourceOption const MGLGeoJSONMaximumZoomLevelOption; /** An `NSNumber` object containing an integer; specifies the size of the tile @@ -41,14 +46,14 @@ extern NSString * const MGLGeoJSONMaximumZoomLevelOption; buffer as wide as the tile itself. Larger values produce fewer rendering artifacts near tile edges and slower performance. The default value is 128. */ -extern NSString * const MGLGeoJSONBufferOption; +extern MGLGeoJSONSourceOption const MGLGeoJSONBufferOption; /** An `NSNumber` object containing a double; specifies the Douglas-Peucker simplification tolerance. A greater value produces simpler geometries and improves performance. The default value is 0.375. */ -extern NSString * const MGLGeoJSONToleranceOption; +extern MGLGeoJSONSourceOption const MGLGeoJSONToleranceOption; /** A GeoJSON source. @@ -71,7 +76,7 @@ extern NSString * const MGLGeoJSONToleranceOption; @param options An `NSDictionary` of options for this source. @return An initialized GeoJSON source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier geoJSONData:(NSData *)data options:(nullable NS_DICTIONARY_OF(NSString *, id) *)options NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier geoJSONData:(NSData *)data options:(nullable NS_DICTIONARY_OF(MGLGeoJSONSourceOption, id) *)options NS_DESIGNATED_INITIALIZER; /** Returns a GeoJSON source with an identifier, URL, and dictionary of options for @@ -85,7 +90,7 @@ extern NSString * const MGLGeoJSONToleranceOption; @param options An `NSDictionary` of options for this source. @return An initialized GeoJSON source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url options:(nullable NS_DICTIONARY_OF(NSString *, id) *)options NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier URL:(NSURL *)url options:(nullable NS_DICTIONARY_OF(MGLGeoJSONSourceOption, id) *)options NS_DESIGNATED_INITIALIZER; /** Returns a GeoJSON source with an identifier, features dictionary, and dictionary @@ -98,7 +103,7 @@ extern NSString * const MGLGeoJSONToleranceOption; @param options An `NSDictionary` of options for this source. @return An initialized GeoJSON source. */ -- (instancetype)initWithIdentifier:(NSString *)identifier features:(NSArray<id<MGLFeature>> *)features options:(nullable NS_DICTIONARY_OF(NSString *,id) *)options NS_DESIGNATED_INITIALIZER; +- (instancetype)initWithIdentifier:(NSString *)identifier features:(NSArray<id<MGLFeature>> *)features options:(nullable NS_DICTIONARY_OF(MGLGeoJSONSourceOption,id) *)options NS_DESIGNATED_INITIALIZER; #pragma mark Accessing a Source’s Content diff --git a/platform/darwin/src/MGLOfflineStorage.h b/platform/darwin/src/MGLOfflineStorage.h index 211135f84f..c6676cf0bd 100644 --- a/platform/darwin/src/MGLOfflineStorage.h +++ b/platform/darwin/src/MGLOfflineStorage.h @@ -24,7 +24,7 @@ NS_ASSUME_NONNULL_BEGIN alternatively observe KVO change notifications to the pack’s `progress` key path. */ -extern NSString * const MGLOfflinePackProgressChangedNotification; +extern NSNotificationName const MGLOfflinePackProgressChangedNotification; /** Posted by the shared `MGLOfflineStorage` object whenever an `MGLOfflinePack` @@ -37,7 +37,7 @@ extern NSString * const MGLOfflinePackProgressChangedNotification; `userInfo` dictionary contains the error object in the `MGLOfflinePackErrorUserInfoKey` key. */ -extern NSString * const MGLOfflinePackErrorNotification; +extern NSNotificationName const MGLOfflinePackErrorNotification; /** Posted by the shared `MGLOfflineStorage` object when the maximum number of @@ -52,7 +52,12 @@ extern NSString * const MGLOfflinePackErrorNotification; calling the `-[MGLOfflineStorage removePack:withCompletionHandler:]` method. Contact your Mapbox sales representative to have the limit raised. */ -extern NSString * const MGLOfflinePackMaximumMapboxTilesReachedNotification; +extern NSNotificationName const MGLOfflinePackMaximumMapboxTilesReachedNotification; + +/** + A key in the `userInfo` property of a notification posted by `MGLOfflinePack`. + */ +typedef NSString *MGLOfflinePackUserInfoKey NS_EXTENSIBLE_STRING_ENUM; /** The key for an `NSNumber` object that indicates an offline pack’s current @@ -60,7 +65,7 @@ extern NSString * const MGLOfflinePackMaximumMapboxTilesReachedNotification; `MGLOfflinePackProgressChangedNotification` notification. Call `-integerValue` on the object to receive the `MGLOfflinePackState`-typed state. */ -extern NSString * const MGLOfflinePackStateUserInfoKey; +extern MGLOfflinePackUserInfoKey const MGLOfflinePackStateUserInfoKey; /** The key for an `NSValue` object that indicates an offline pack’s current @@ -69,7 +74,7 @@ extern NSString * const MGLOfflinePackStateUserInfoKey; `-MGLOfflinePackProgressValue` on the object to receive the `MGLOfflinePackProgress`-typed progress. */ -extern NSString * const MGLOfflinePackProgressUserInfoKey; +extern MGLOfflinePackUserInfoKey const MGLOfflinePackProgressUserInfoKey; /** The key for an `NSError` object that is encountered in the course of @@ -77,7 +82,7 @@ extern NSString * const MGLOfflinePackProgressUserInfoKey; an `MGLOfflinePackErrorNotification` notification. The error’s domain is `MGLErrorDomain`. See `MGLErrorCode` for possible error codes. */ -extern NSString * const MGLOfflinePackErrorUserInfoKey; +extern MGLOfflinePackUserInfoKey const MGLOfflinePackErrorUserInfoKey; /** The key for an `NSNumber` object that indicates the maximum number of @@ -87,7 +92,7 @@ extern NSString * const MGLOfflinePackErrorUserInfoKey; `-unsignedLongLongValue` on the object to receive the `uint64_t`-typed tile limit. */ -extern NSString * const MGLOfflinePackMaximumCountUserInfoKey; +extern MGLOfflinePackUserInfoKey const MGLOfflinePackMaximumCountUserInfoKey; /** A block to be called once an offline pack has been completely created and diff --git a/platform/darwin/src/MGLTypes.h b/platform/darwin/src/MGLTypes.h index a3ea587add..a1367e2d61 100644 --- a/platform/darwin/src/MGLTypes.h +++ b/platform/darwin/src/MGLTypes.h @@ -21,7 +21,7 @@ NS_ASSUME_NONNULL_BEGIN /** Indicates an error occurred in the Mapbox SDK. */ -extern NSString * const MGLErrorDomain; +extern NSErrorDomain const MGLErrorDomain; /** Error constants for the Mapbox SDK. */ typedef NS_ENUM(NSInteger, MGLErrorCode) { @@ -97,3 +97,9 @@ NS_ASSUME_NONNULL_END #define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary #endif #endif + +#if !defined(FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST) || !FOUNDATION_SWIFT_SDK_EPOCH_AT_LEAST(8) + #define NS_STRING_ENUM + #define NS_EXTENSIBLE_STRING_ENUM + #define NSNotificationName NSString * +#endif diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index bc6a8145ee..b552deccbd 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -76,6 +76,7 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT ### Other changes * As the user zooms in, tiles from lower zoom levels are scaled up until tiles for higher zoom levels are loaded. ([#5143](https://github.com/mapbox/mapbox-gl-native/pull/5143)) +* Notification names and user info keys are now string enumeration values for ease of use in Swift. ([#6794](https://github.com/mapbox/mapbox-gl-native/pull/6794)) * MGLMapDebugOverdrawVisualizationMask no longer has any effect in Release builds of the SDK. This debug mask has been disabled for performance reasons. ([#5555](https://github.com/mapbox/mapbox-gl-native/pull/5555)) * Fixed a typo in the documentation for the MGLCompassDirectionFormatter class. ([#5879](https://github.com/mapbox/mapbox-gl-native/pull/5879)) diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 388eb07b04..9f08e5de9d 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -53,6 +53,7 @@ ### Other changes * Fixed an issue where the map view’s center would always be calculated as if the view occupied the entire window. ([#6102](https://github.com/mapbox/mapbox-gl-native/pull/6102)) +* Notification names and user info keys are now string enumeration values for ease of use in Swift. ([#6794](https://github.com/mapbox/mapbox-gl-native/pull/6794)) * Fixed a typo in the documentation for the MGLCompassDirectionFormatter class. ([#5879](https://github.com/mapbox/mapbox-gl-native/pull/5879)) ## 0.2.1 - July 19, 2016 |