diff options
author | Minh Nguyễn <mxn@1ec5.org> | 2016-03-27 22:40:15 -0700 |
---|---|---|
committer | Minh Nguyễn <mxn@1ec5.org> | 2016-03-29 11:46:27 -0700 |
commit | 8c8b0580388460c0addafb49c852ea8986b47ac4 (patch) | |
tree | 2e55e038689eba4d0faf71c251adca8543ea8075 /platform/darwin/include | |
parent | aff1196d02cd06e71c7b2a15454384fd302946b1 (diff) | |
download | qtlocation-mapboxgl-8c8b0580388460c0addafb49c852ea8986b47ac4.tar.gz |
[ios, osx] Include progress in progress change notification
An MGLOfflinePackProgressChangedNotification notification now includes the pack’s state and progress values, which match the values in the corresponding MGLOfflinePack properties. Implemented NSValue category methods to store MGLOfflinePackProgress inside a dictionary.
Diffstat (limited to 'platform/darwin/include')
-rw-r--r-- | platform/darwin/include/MGLOfflinePack.h | 21 | ||||
-rw-r--r-- | platform/darwin/include/MGLOfflineStorage.h | 35 |
2 files changed, 50 insertions, 6 deletions
diff --git a/platform/darwin/include/MGLOfflinePack.h b/platform/darwin/include/MGLOfflinePack.h index 185bba038c..b65fed3849 100644 --- a/platform/darwin/include/MGLOfflinePack.h +++ b/platform/darwin/include/MGLOfflinePack.h @@ -161,4 +161,25 @@ typedef struct MGLOfflinePackProgress { @end +/** + Methods for round-tripping `MGLOfflinePackProgress` values. + */ +@interface NSValue (MGLOfflinePackAdditions) + +/** + Creates a new value object containing the given `MGLOfflinePackProgress` + structure. + + @param progress The value for the new object. + @return A new value object that contains the offline pack progress information. + */ ++ (NSValue *)valueWithMGLOfflinePackProgress:(MGLOfflinePackProgress)progress; + +/** + The `MGLOfflinePackProgress` structure representation of the value. + */ +@property (readonly) MGLOfflinePackProgress MGLOfflinePackProgressValue; + +@end + NS_ASSUME_NONNULL_END diff --git a/platform/darwin/include/MGLOfflineStorage.h b/platform/darwin/include/MGLOfflineStorage.h index f9ddba0382..5544663d3e 100644 --- a/platform/darwin/include/MGLOfflineStorage.h +++ b/platform/darwin/include/MGLOfflineStorage.h @@ -14,8 +14,11 @@ NS_ASSUME_NONNULL_BEGIN resources are required for offline viewing. This notification is posted whenever any field in the `progress` property changes. - The `object` is the `MGLOfflinePack` object whose progress changed. For details - about the pack’s current progress, use the pack’s `progress` property. + The `object` is the `MGLOfflinePack` object whose progress changed. The + `userInfo` dictionary contains the pack’s current state in the + `MGLOfflinePackStateUserInfoKey` key and details about the pack’s current + progress in the `MGLOfflinePackProgressUserInfoKey` key. You may also consult + the pack’s `state` and `progress` properties, which provide the same values. If you only need to observe changes in a particular pack’s progress, you can alternatively observe KVO change notifications to the pack’s `progress` key @@ -52,17 +55,37 @@ extern NSString * const MGLOfflinePackErrorNotification; extern NSString * const MGLOfflinePackMaximumMapboxTilesReachedNotification; /** + The key for an `NSNumber` object that indicates an offline pack’s current + state. This key is used in the `userInfo` dictionary of an + `MGLOfflinePackProgressChangedNotification` notification. Call `-integerValue` + on the object to receive the `MGLOfflinePackState`-typed state. + */ +extern NSString * const MGLOfflinePackStateUserInfoKey; + +/** + The key for an `NSValue` object that indicates an offline pack’s current + progress. This key is used in the `userInfo` dictionary of an + `MGLOfflinePackProgressChangedNotification` notification. Call + `-MGLOfflinePackProgressValue` on the object to receive the + `MGLOfflinePackProgress`-typed progress. + */ +extern NSString * const MGLOfflinePackProgressUserInfoKey; + +/** The key for an `NSError` object that is encountered in the course of - downloading an offline pack. The error’s domain is `MGLErrorDomain`. See - `MGLErrorCode` for possible error codes. + downloading an offline pack. This key is used in the `userInfo` dictionary of + an `MGLOfflinePackErrorNotification` notification. The error’s domain is + `MGLErrorDomain`. See `MGLErrorCode` for possible error codes. */ extern NSString * const MGLOfflinePackErrorUserInfoKey; /** The key for an `NSNumber` object that indicates the maximum number of Mapbox-hosted tiles that may be downloaded and stored on the current device. - Call `-unsignedLongLongValue` on the object to receive the `uint64_t`-typed - tile limit. + This key is used in the `userInfo` dictionary of an + `MGLOfflinePackMaximumMapboxTilesReachedNotification` notification. Call + `-unsignedLongLongValue` on the object to receive the `uint64_t`-typed tile + limit. */ extern NSString * const MGLOfflinePackMaximumCountUserInfoKey; |