summaryrefslogtreecommitdiff
path: root/include/mbgl
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 /include/mbgl
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 'include/mbgl')
-rw-r--r--include/mbgl/ios/MGLMapView.h12
-rw-r--r--include/mbgl/ios/MGLTypes.h20
2 files changed, 26 insertions, 6 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