summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-06-11 12:30:52 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-06-17 15:33:00 -0700
commit91641ffb01dcf8d303b13216797bb41d1f770124 (patch)
treeebf706053d5190431b82c6bccf0623c0ab18075a /platform
parent73737445ec0333b701b64613d8b92e18f45ea314 (diff)
downloadqtlocation-mapboxgl-91641ffb01dcf8d303b13216797bb41d1f770124.tar.gz
Lightweight generics
Added lightweight generics annotations to collection-typed method and protocol signatures to streamline usage of these members in Swift. Lightweight generic type specifiers are wrapped in conditionally-compiled macros for compatibility with Xcode 6.x. Manually preprocess the NS_*_OF() macros in a temporary copy of each header before appledoc sees the headers. Also removed the --ignore flag because we no longer have a private headers folder under include/mbgl/ios/.
Diffstat (limited to 'platform')
-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
4 files changed, 41 insertions, 36 deletions
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"];
}