summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/ios/MGLMapView.h12
-rw-r--r--include/mbgl/ios/MGLTypes.h20
-rw-r--r--platform/ios/MGLMapView.mm46
-rw-r--r--platform/ios/MGLMapboxEvents.h5
-rw-r--r--platform/ios/MGLMapboxEvents.m24
-rw-r--r--platform/ios/MGLUserLocation.m2
-rwxr-xr-xscripts/ios/package.sh13
7 files changed, 77 insertions, 45 deletions
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index 26a5051d41..abe7f851a1 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -171,7 +171,7 @@ IB_DESIGNABLE
@property (nonatomic, nullable) NSString *mapID __attribute__((unavailable("Use styleID.")));
/** URLs of the styles bundled with the library. */
-@property (nonatomic, readonly) NSArray *bundledStyleURLs;
+@property (nonatomic, readonly) NS_ARRAY_OF(NSURL *) *bundledStyleURLs;
/** URL of the style currently displayed in the receiver.
*
@@ -181,7 +181,7 @@ IB_DESIGNABLE
@property (nonatomic, null_resettable) NSURL *styleURL;
/** Currently active style classes, represented as an array of string identifiers. */
-@property (nonatomic) NSArray *styleClasses;
+@property (nonatomic) NS_ARRAY_OF(NSString *) *styleClasses;
/** Returns a Boolean value indicating whether the style class with the given identifier is currently active.
@param styleClass The style class to query for.
@@ -203,7 +203,7 @@ IB_DESIGNABLE
/** The complete list of annotations associated with the receiver. (read-only)
*
* The objects in this array must adopt the MGLAnnotation protocol. If no annotations are associated with the map view, the value of this property is `nil`. */
-@property (nonatomic, readonly, nullable) NSArray *annotations;
+@property (nonatomic, readonly, nullable) NS_ARRAY_OF(id <MGLAnnotation>) *annotations;
/** Adds the specified annotation to the map view.
* @param annotation The annotation object to add to the receiver. This object must conform to the MGLAnnotation protocol. The map view retains the specified object. */
@@ -211,7 +211,7 @@ IB_DESIGNABLE
/** Adds an array of annotation objects to the map view.
* @param annotations An array of annotation objects. Each object in the array must conform to the MGLAnnotation protocol. The map view retains the individual annotation objects. */
-- (void)addAnnotations:(NSArray *)annotations;
+- (void)addAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations;
/** Removes the specified annotation object from the map view.
*
@@ -225,12 +225,12 @@ IB_DESIGNABLE
* Removing annotation objects disassociates them from the map view entirely, preventing them from being displayed on the map. Thus, you would typically call this method only when you want to hide or delete the specified annotations.
*
* @param annotations The array of annotations to remove. Objects in the array must conform to the MGLAnnotation protocol. */
-- (void)removeAnnotations:(NSArray *)annotations;
+- (void)removeAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations;
/** The annotations that are currently selected.
*
* Assigning a new array to this property selects only the first annotation in the array. */
-@property (nonatomic, copy) NSArray *selectedAnnotations;
+@property (nonatomic, copy) NS_ARRAY_OF(id <MGLAnnotation>) *selectedAnnotations;
/** Selects the specified annotation and displays a callout view for it.
*
diff --git a/include/mbgl/ios/MGLTypes.h b/include/mbgl/ios/MGLTypes.h
index 3d3892610a..65d5e7846d 100644
--- a/include/mbgl/ios/MGLTypes.h
+++ b/include/mbgl/ios/MGLTypes.h
@@ -29,3 +29,23 @@ typedef struct {
} MGLCoordinateBounds;
NS_ASSUME_NONNULL_END
+
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wvariadic-macros"
+ #if __has_feature(objc_generics)
+ /** Inserts a type specifier for a pointer to a lightweight generic with the given collection and object classes. Use a `*` for any non-`id` object classes but no `*` for the collection class. */
+ #define NS_ARRAY_OF(ObjectClass...) NSArray <ObjectClass>
+ #define NS_MUTABLE_ARRAY_OF(ObjectClass...) NSMutableArray <ObjectClass>
+ #define NS_SET_OF(ObjectClass...) NSSet <ObjectClass>
+ #define NS_MUTABLE_SET_OF(ObjectClass...) NSMutableSet <ObjectClass>
+ #define NS_DICTIONARY_OF(ObjectClass...) NSDictionary <ObjectClass>
+ #define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary <ObjectClass>
+ #else
+ #define NS_ARRAY_OF(ObjectClass...) NSArray
+ #define NS_MUTABLE_ARRAY_OF(ObjectClass...) NSMutableArray
+ #define NS_SET_OF(ObjectClass...) NSSet
+ #define NS_MUTABLE_SET_OF(ObjectClass...) NSMutableSet
+ #define NS_DICTIONARY_OF(ObjectClass...) NSDictionary
+ #define NS_MUTABLE_DICTIONARY_OF(ObjectClass...) NSMutableDictionary
+ #endif
+#pragma clang diagnostic pop
diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm
index 63e3b516ab..40eeec0ec6 100644
--- a/platform/ios/MGLMapView.mm
+++ b/platform/ios/MGLMapView.mm
@@ -97,7 +97,7 @@ CLLocationDegrees MGLDegreesFromRadians(CGFloat radians)
MBGLView *_mbglView;
mbgl::DefaultFileSource *_mbglFileSource;
- NSMutableArray *_bundledStyleURLs;
+ NS_MUTABLE_ARRAY_OF(NSURL *) *_bundledStyleURLs;
BOOL _isTargetingInterfaceBuilder;
CLLocationDegrees _pendingLatitude;
@@ -154,7 +154,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
NSAssert(NO, @"-[MGLMapView setAccessToken:] has been replaced by +[MGLAccountManager setAccessToken:].\n\nIf you previously set this access token in a storyboard inspectable, select the MGLMapView in Interface Builder and delete the “accessToken” entry from the User Defined Runtime Attributes section of the Identity inspector. Then go to the Info.plist file and set MGLMapboxAccessToken to “%@”.", accessToken);
}
-+ (NSSet *)keyPathsForValuesAffectingStyleURL
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleURL
{
return [NSSet setWithObject:@"styleID"];
}
@@ -728,7 +728,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
if (self.userTrackingMode == MGLUserTrackingModeFollowWithHeading) self.userTrackingMode = MGLUserTrackingModeFollow;
}
-- (void)touchesBegan:(__unused NSSet *)touches withEvent:(__unused UIEvent *)event
+- (void)touchesBegan:(__unused NS_SET_OF(UITouch *) *)touches withEvent:(__unused UIEvent *)event
{
_mbglMap->cancelTransitions();
_mbglMap->setGestureInProgress(false);
@@ -1294,17 +1294,17 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
}
}
-+ (NSSet *)keyPathsForValuesAffectingZoomEnabled
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingZoomEnabled
{
return [NSSet setWithObject:@"allowsZooming"];
}
-+ (NSSet *)keyPathsForValuesAffectingScrollEnabled
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingScrollEnabled
{
return [NSSet setWithObject:@"allowsScrolling"];
}
-+ (NSSet *)keyPathsForValuesAffectingRotateEnabled
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingRotateEnabled
{
return [NSSet setWithObject:@"allowsRotating"];
}
@@ -1365,7 +1365,7 @@ std::chrono::steady_clock::duration secondsAsDuration(float duration)
#pragma mark - Geography -
-+ (NSSet *)keyPathsForValuesAffectingCenterCoordinate
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingCenterCoordinate
{
return [NSSet setWithObjects:@"latitude", @"longitude", nil];
}
@@ -1535,7 +1535,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
#pragma mark - Styling -
-- (NSArray *)bundledStyleURLs
+- (NS_ARRAY_OF(NSURL *) *)bundledStyleURLs
{
if ( ! _bundledStyleURLs)
{
@@ -1553,7 +1553,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
return [NSArray arrayWithArray:_bundledStyleURLs];
}
-+ (NSSet *)keyPathsForValuesAffectingStyleID
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingStyleID
{
return [NSSet setWithObject:@"styleURL"];
}
@@ -1580,7 +1580,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
NSAssert(NO, @"-[MGLMapView setMapID:] has been renamed -[MGLMapView setStyleID:].\n\nIf you previously set this map ID in a storyboard inspectable, select the MGLMapView in Interface Builder and delete the “mapID” entry from the User Defined Runtime Attributes section of the Identity inspector. Then go to the Attributes inspector and enter “%@” into the “Style ID” field.", mapID);
}
-- (NSArray *)styleClasses
+- (NS_ARRAY_OF(NSString *) *)styleClasses
{
NSMutableArray *returnArray = [NSMutableArray array];
@@ -1594,12 +1594,12 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
return returnArray;
}
-- (void)setStyleClasses:(NSArray *)appliedClasses
+- (void)setStyleClasses:(NS_ARRAY_OF(NSString *) *)appliedClasses
{
[self setStyleClasses:appliedClasses transitionDuration:0];
}
-- (void)setStyleClasses:(NSArray *)appliedClasses transitionDuration:(NSTimeInterval)transitionDuration
+- (void)setStyleClasses:(NS_ARRAY_OF(NSString *) *)appliedClasses transitionDuration:(NSTimeInterval)transitionDuration
{
std::vector<std::string> newAppliedClasses;
@@ -1635,7 +1635,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
#pragma mark - Annotations -
-- (nullable NSArray *)annotations
+- (nullable NS_ARRAY_OF(id <MGLAnnotation>) *)annotations
{
if ([_annotationIDsByAnnotation count])
{
@@ -1665,7 +1665,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
[self addAnnotations:@[ annotation ]];
}
-- (void)addAnnotations:(NSArray *)annotations
+- (void)addAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations
{
if ( ! annotations) return;
@@ -1808,7 +1808,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
[self removeAnnotations:@[ annotation ]];
}
-- (void)removeAnnotations:(NSArray *)annotations
+- (void)removeAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)annotations
{
if ( ! annotations) return;
@@ -1832,12 +1832,12 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
_mbglMap->removeAnnotations(annotationIDsToRemove);
}
-- (NSArray *)selectedAnnotations
+- (NS_ARRAY_OF(id <MGLAnnotation>) *)selectedAnnotations
{
return (self.selectedAnnotation ? @[ self.selectedAnnotation ] : @[]);
}
-- (void)setSelectedAnnotations:(NSArray *)selectedAnnotations
+- (void)setSelectedAnnotations:(NS_ARRAY_OF(id <MGLAnnotation>) *)selectedAnnotations
{
if ( ! selectedAnnotations.count) return;
@@ -2038,7 +2038,7 @@ CLLocationCoordinate2D MGLLocationCoordinate2DFromLatLng(mbgl::LatLng latLng)
}
}
-+ (NSSet *)keyPathsForValuesAffectingUserLocation
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingUserLocation
{
return [NSSet setWithObject:@"userLocationAnnotationView"];
}
@@ -2732,7 +2732,7 @@ class MBGLView : public mbgl::View
@implementation MGLMapView (IBAdditions)
-+ (NSSet *)keyPathsForValuesAffectingLatitude
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingLatitude
{
return [NSSet setWithObject:@"centerCoordinate"];
}
@@ -2758,7 +2758,7 @@ class MBGLView : public mbgl::View
}
}
-+ (NSSet *)keyPathsForValuesAffectingLongitude
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingLongitude
{
return [NSSet setWithObject:@"centerCoordinate"];
}
@@ -2784,7 +2784,7 @@ class MBGLView : public mbgl::View
}
}
-+ (NSSet *)keyPathsForValuesAffectingAllowsZooming
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingAllowsZooming
{
return [NSSet setWithObject:@"zoomEnabled"];
}
@@ -2799,7 +2799,7 @@ class MBGLView : public mbgl::View
self.zoomEnabled = allowsZooming;
}
-+ (NSSet *)keyPathsForValuesAffectingAllowsScrolling
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingAllowsScrolling
{
return [NSSet setWithObject:@"scrollEnabled"];
}
@@ -2814,7 +2814,7 @@ class MBGLView : public mbgl::View
self.scrollEnabled = allowsScrolling;
}
-+ (NSSet *)keyPathsForValuesAffectingAllowsRotating
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingAllowsRotating
{
return [NSSet setWithObject:@"rotateEnabled"];
}
diff --git a/platform/ios/MGLMapboxEvents.h b/platform/ios/MGLMapboxEvents.h
index 8ca0832910..9efb53c5ea 100644
--- a/platform/ios/MGLMapboxEvents.h
+++ b/platform/ios/MGLMapboxEvents.h
@@ -31,6 +31,9 @@ extern NSString *const MGLEventGesturePanStart;
extern NSString *const MGLEventGesturePinchStart;
extern NSString *const MGLEventGestureRotateStart;
+typedef NS_DICTIONARY_OF(NSString *, id) MGLMapboxEventAttributes;
+typedef NS_MUTABLE_DICTIONARY_OF(NSString *, id) MGLMutableMapboxEventAttributes;
+
@interface MGLMapboxEvents : NSObject <NSURLSessionDelegate>
+ (nullable instancetype)sharedManager;
@@ -49,7 +52,7 @@ extern NSString *const MGLEventGestureRotateStart;
// Copy any values needed first or create dedicated methods in this
// class for threadsafe access to UIKit classes.
//
-+ (void) pushEvent:(NSString *)event withAttributes:(NSDictionary *)attributeDictionary;
++ (void) pushEvent:(NSString *)event withAttributes:(MGLMapboxEventAttributes *)attributeDictionary;
// You can call these methods from any thread.
//
diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index 9125b56fdd..400bd8360e 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -165,7 +165,7 @@ const NSTimeInterval MGLFlushInterval = 60;
// This is an array of events to push. All access to it will be
// from our own serial queue.
//
-@property (nonatomic) NSMutableArray *eventQueue;
+@property (nonatomic) NS_MUTABLE_ARRAY_OF(MGLMapboxEventAttributes *) *eventQueue;
// This is a custom serial queue for accessing the event queue.
//
@@ -447,12 +447,14 @@ const NSTimeInterval MGLFlushInterval = 60;
// Build only IDFV event
NSString *vid = [[[UIDevice currentDevice] identifierForVendor] UUIDString];
- NSDictionary *vevt = @{@"event" : MGLEventTypeAppUserTurnstile,
- @"created" : [strongSelf.rfc3339DateFormatter stringFromDate:[NSDate date]],
- @"appBundleId" : strongSelf.appBundleId,
- @"vendorId": vid,
- @"version": @(version),
- @"instance": strongSelf.instanceID};
+ NSDictionary *vevt = @{
+ @"event" : MGLEventTypeAppUserTurnstile,
+ @"created" : [strongSelf.rfc3339DateFormatter stringFromDate:[NSDate date]],
+ @"appBundleId" : strongSelf.appBundleId,
+ @"vendorId": vid,
+ @"version": @(version),
+ @"instance": strongSelf.instanceID
+ };
// Add to Queue
[_eventQueue addObject:vevt];
@@ -465,7 +467,7 @@ const NSTimeInterval MGLFlushInterval = 60;
// Can be called from any thread. Can be called rapidly from
// the UI thread, so performance is paramount.
//
-+ (void) pushEvent:(NSString *)event withAttributes:(NSDictionary *)attributeDictionary {
++ (void) pushEvent:(NSString *)event withAttributes:(MGLMapboxEventAttributes *)attributeDictionary {
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
[[MGLMapboxEvents sharedManager] pushEvent:event withAttributes:attributeDictionary];
});
@@ -474,7 +476,7 @@ const NSTimeInterval MGLFlushInterval = 60;
// Can be called from any thread. Called implicitly from public
// use of +pushEvent:withAttributes:.
//
-- (void) pushEvent:(NSString *)event withAttributes:(NSDictionary *)attributeDictionary {
+- (void) pushEvent:(NSString *)event withAttributes:(MGLMapboxEventAttributes *)attributeDictionary {
__weak MGLMapboxEvents *weakSelf = self;
dispatch_async(_serialQueue, ^{
@@ -490,7 +492,7 @@ const NSTimeInterval MGLFlushInterval = 60;
if (!event) return;
- NSMutableDictionary *evt = [[NSMutableDictionary alloc] initWithDictionary:attributeDictionary];
+ MGLMutableMapboxEventAttributes *evt = [MGLMutableMapboxEventAttributes dictionaryWithDictionary:attributeDictionary];
// mapbox-events stock attributes
[evt setObject:event forKey:@"event"];
[evt setObject:@(version) forKey:@"version"];
@@ -577,7 +579,7 @@ const NSTimeInterval MGLFlushInterval = 60;
// Can be called from any thread. Called implicitly from public
// use of +flush. Posts an async network request to upload metrics.
//
-- (void) postEvents:(NSArray *)events {
+- (void) postEvents:(NS_ARRAY_OF(MGLMapboxEventAttributes *) *)events {
__weak MGLMapboxEvents *weakSelf = self;
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{
diff --git a/platform/ios/MGLUserLocation.m b/platform/ios/MGLUserLocation.m
index 201e54605e..0b0cf70cbe 100644
--- a/platform/ios/MGLUserLocation.m
+++ b/platform/ios/MGLUserLocation.m
@@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_END
return ! [key isEqualToString:@"location"] && ! [key isEqualToString:@"heading"];
}
-+ (NSSet *)keyPathsForValuesAffectingCoordinate
++ (NS_SET_OF(NSString *) *)keyPathsForValuesAffectingCoordinate
{
return [NSSet setWithObject:@"location"];
}
diff --git a/scripts/ios/package.sh b/scripts/ios/package.sh
index cccaa4aad2..5d7cbdc32d 100755
--- a/scripts/ios/package.sh
+++ b/scripts/ios/package.sh
@@ -110,11 +110,19 @@ if [ -z `which appledoc` ]; then
fi
DOCS_OUTPUT="${OUTPUT}/static/Docs"
DOCS_VERSION=$( git tag -l ios\* --sort -v:refname | sed -n '1p' | sed 's/^v//' )
-README="/tmp/GL-README.md"
+rm -rf /tmp/mbgl
+mkdir -p /tmp/mbgl/
+README=/tmp/mbgl/GL-README.md
cat ios/README.md > ${README}
echo >> ${README}
echo -n "#" >> ${README}
cat CHANGELOG.md >> ${README}
+# Copy headers to a temporary location where we can substitute macros that appledoc doesn't understand.
+cp -r "${OUTPUT}/static/Headers" /tmp/mbgl
+perl \
+ -pi \
+ -e 's/NS_(?:(MUTABLE)_)?(ARRAY|SET|DICTIONARY)_OF\(\s*(.+?)\s*\)/NS\L\u$1\u$2\E <$3>/g' \
+ /tmp/mbgl/Headers/*.h
appledoc \
--output ${DOCS_OUTPUT} \
--project-name "Mapbox GL for iOS ${DOCS_VERSION}" \
@@ -123,6 +131,5 @@ appledoc \
--no-create-docset \
--no-install-docset \
--company-id com.mapbox \
- --ignore include/mbgl/ios/private \
--index-desc ${README} \
- include/mbgl/ios
+ /tmp/mbgl/Headers