summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorMinh Nguyễn <mxn@1ec5.org>2015-05-16 21:28:49 -0700
committerMinh Nguyễn <mxn@1ec5.org>2015-06-11 11:37:23 -0700
commitf46328655e027bf490692fcde4aab770912aac8d (patch)
tree4be947bf81e7f42392aafe6874f4ded5e21e5ace /include
parentcfee5aa8ef73b5bd2050bd68d584846192ebf0a2 (diff)
downloadqtlocation-mapboxgl-f46328655e027bf490692fcde4aab770912aac8d.tar.gz
Audited headers for nullability
Added some nullability qualifiers in method implementation selectors for consistency with declarations. The user dot view now has a non-zero size. Previously only its layer was sized properly. Also resolved some pedantic warnings about missing designated initializer overrides. Xcode 6.3 or above is now required for building this project.
Diffstat (limited to 'include')
-rw-r--r--include/mbgl/ios/MGLAccountManager.h10
-rw-r--r--include/mbgl/ios/MGLAnnotation.h9
-rw-r--r--include/mbgl/ios/MGLMapView+IBAdditions.h7
-rw-r--r--include/mbgl/ios/MGLMapView.h38
-rw-r--r--include/mbgl/ios/MGLTypes.h4
-rw-r--r--include/mbgl/ios/MGLUserLocation.h10
6 files changed, 52 insertions, 26 deletions
diff --git a/include/mbgl/ios/MGLAccountManager.h b/include/mbgl/ios/MGLAccountManager.h
index 6b127543ee..2efabf8941 100644
--- a/include/mbgl/ios/MGLAccountManager.h
+++ b/include/mbgl/ios/MGLAccountManager.h
@@ -1,4 +1,6 @@
-#import <Foundation/Foundation.h>
+#import "MGLTypes.h"
+
+NS_ASSUME_NONNULL_BEGIN
/** The MGLAccountManager object provides a global way to set a Mapbox API access token, as well as other settings used framework-wide. */
@interface MGLAccountManager : NSObject
@@ -9,13 +11,13 @@
*
* You can set an access token on MGLAccountManager or on an individual map view. The same token is used throughout the framework.
* @param accessToken The Mapbox API access token. */
-+ (void)setAccessToken:(NSString *)accessToken;
++ (void)setAccessToken:(nullable NSString *)accessToken;
/** Retreive the Mapbox API access token for the framework.
*
* You can set an access token on MGLAccountManager or on an individual map view. The same token is used throughout the framework.
* @return accessToken The Mapbox API access token. */
-+ (NSString *)accessToken;
++ (nullable NSString *)accessToken;
/** @name Providing User Metrics Opt-Out */
@@ -27,3 +29,5 @@
+ (BOOL)mapboxMetricsEnabledSettingShownInApp;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/include/mbgl/ios/MGLAnnotation.h b/include/mbgl/ios/MGLAnnotation.h
index e4907d9b94..0d45f15e44 100644
--- a/include/mbgl/ios/MGLAnnotation.h
+++ b/include/mbgl/ios/MGLAnnotation.h
@@ -1,6 +1,9 @@
-#import <Foundation/Foundation.h>
#import <CoreLocation/CoreLocation.h>
+#import "MGLTypes.h"
+
+NS_ASSUME_NONNULL_BEGIN
+
/** The MGLAnnotation protocol is used to provide annotation-related information to a map view. To use this protocol, you adopt it in any custom objects that store or represent annotation data. Each object then serves as the source of information about a single map annotation and provides critical information, such as the annotation’s location on the map. Annotation objects do not provide the visual representation of the annotation but typically coordinate (in conjunction with the map view’s delegate) the creation of an appropriate objects to handle the display.
*
* An object that adopts this protocol must implement the `coordinate` property. The other methods of this protocol are optional. */
@@ -23,6 +26,8 @@
/** The string containing the annotation’s subtitle.
*
* This string is displayed in the callout for the associated annotation. */
-@property (nonatomic, readonly, copy) NSString *subtitle;
+@property (nonatomic, readonly, copy, nullable) NSString *subtitle;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/include/mbgl/ios/MGLMapView+IBAdditions.h b/include/mbgl/ios/MGLMapView+IBAdditions.h
index 23762cca94..693457413f 100644
--- a/include/mbgl/ios/MGLMapView+IBAdditions.h
+++ b/include/mbgl/ios/MGLMapView+IBAdditions.h
@@ -1,4 +1,7 @@
#import "MGLMapView.h"
+#import "MGLTypes.h"
+
+NS_ASSUME_NONNULL_BEGIN
@interface MGLMapView (IBAdditions)
@@ -8,7 +11,7 @@
// inspectables declared in MGLMapView.h are always sorted before those in
// MGLMapView+IBAdditions.h, due to ASCII sort order.
-@property (nonatomic) IBInspectable NSString *styleID;
+@property (nonatomic, nullable) IBInspectable NSString *styleID;
// Convenience properties related to the initial viewport. These properties
// are not meant to be used outside of Interface Builder. latitude and longitude
@@ -30,3 +33,5 @@
@property (nonatomic) IBInspectable BOOL showsUserLocation;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h
index 0ccb8225bb..29cb682713 100644
--- a/include/mbgl/ios/MGLMapView.h
+++ b/include/mbgl/ios/MGLMapView.h
@@ -3,6 +3,8 @@
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>
+NS_ASSUME_NONNULL_BEGIN
+
@class MGLUserLocation;
@protocol MGLMapViewDelegate;
@@ -28,17 +30,17 @@ IB_DESIGNABLE
/** Initializes and returns a newly allocated map view with the specified frame and style URL.
* @param frame The frame for the view, measured in points.
-* @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://<user.style>`).
+* @param styleURL The map style URL to use. Can be either an HTTP/HTTPS URL or a Mapbox map ID style URL (`mapbox://<user.style>`). Specify `nil` for the default style.
* @return An initialized map view. */
-- (instancetype)initWithFrame:(CGRect)frame styleURL:(NSURL *)styleURL;
-- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(NSURL *)styleURL __attribute__((unavailable("Use -initWithFrame:styleURL:. Set MGLMapboxAccessToken in the Info.plist or call +[MGLAccountManager setAccessToken:].")));
+- (instancetype)initWithFrame:(CGRect)frame styleURL:(nullable NSURL *)styleURL;
+- (instancetype)initWithFrame:(CGRect)frame accessToken:(NSString *)accessToken styleURL:(nullable NSURL *)styleURL __attribute__((unavailable("Use -initWithFrame:styleURL:. Set MGLMapboxAccessToken in the Info.plist or call +[MGLAccountManager setAccessToken:].")));
#pragma mark - Authorizing Access
/** @name Authorizing Access */
/** Mapbox API access token for the map view. */
-@property (nonatomic) NSString *accessToken __attribute__((unavailable("Use +[MGLAccountManager accessToken] and +[MGLAccountManager setAccessToken:].")));
+@property (nonatomic, nullable) NSString *accessToken __attribute__((unavailable("Use +[MGLAccountManager accessToken] and +[MGLAccountManager setAccessToken:].")));
#pragma mark - Managing Constraints
@@ -74,7 +76,7 @@ IB_DESIGNABLE
/** @name Accessing the Delegate */
// TODO
-@property(nonatomic, weak) IBOutlet id<MGLMapViewDelegate> delegate;
+@property(nonatomic, weak, nullable) IBOutlet id<MGLMapViewDelegate> delegate;
#pragma mark - Manipulating the Visible Portion of the Map
@@ -137,13 +139,13 @@ IB_DESIGNABLE
* @param point The point you want to convert.
* @param view The view that serves as the reference coordinate system for the `point` parameter.
* @return The map coordinate at the specified point. */
-- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view;
+- (CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(nullable UIView *)view;
/** Converts a map coordinate to a point in the specified view.
* @param coordinate The map coordinate for which you want to find the corresponding point.
* @param view The view in whose coordinate system you want to locate the specified map coordinate. If this parameter is `nil`, the returned point is specified in the window’s coordinate system. If `view` is not `nil`, it must belong to the same window as the map view.
* @return The point (in the appropriate view or window coordinate system) corresponding to the specified latitude and longitude value. */
-- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(UIView *)view;
+- (CGPoint)convertCoordinate:(CLLocationCoordinate2D)coordinate toPointToView:(nullable UIView *)view;
/** Returns the distance spanned by one pixel at the specified latitude and current zoom level.
*
@@ -162,18 +164,18 @@ IB_DESIGNABLE
* The style may lack an ID if it is located at an HTTP, HTTPS, or local file URL. Use `styleURL` to get the URL in these cases.
*
* To display the default style, set this property to `nil`. */
-@property (nonatomic) NSString *styleID;
-@property (nonatomic) NSString *mapID __attribute__((unavailable("Use styleID.")));
+@property (nonatomic, nullable) NSString *styleID;
+@property (nonatomic, nullable) NSString *mapID __attribute__((unavailable("Use styleID.")));
/** Returns the URLs to the styles bundled with the library. */
-- (NSArray *)bundledStyleURLs;
+@property (nonatomic, readonly) NSArray *bundledStyleURLs;
/** URL of the style currently displayed in the receiver.
*
* The URL may be a full HTTP or HTTPS URL or a Mapbox URL indicating the style’s map ID (`mapbox://<user.style>`).
*
* To display the default style, set this property to `nil`. */
-@property (nonatomic) NSURL *styleURL;
+@property (nonatomic, null_resettable) NSURL *styleURL;
/** Currently active style classes, represented as an array of string identifiers. */
@property (nonatomic) NSArray *styleClasses;
@@ -198,7 +200,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) NSArray *annotations;
+@property (nonatomic, readonly, nullable) NSArray *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. */
@@ -257,7 +259,7 @@ IB_DESIGNABLE
@property (nonatomic, assign, readonly, getter=isUserLocationVisible) BOOL userLocationVisible;
/** Returns the annotation object indicating the user’s current location. */
-@property (nonatomic, readonly) MGLUserLocation *userLocation;
+@property (nonatomic, readonly, nullable) MGLUserLocation *userLocation;
/** The mode used to track the user location. */
@property (nonatomic, assign) MGLUserTrackingMode userTrackingMode;
@@ -300,7 +302,7 @@ IB_DESIGNABLE
* @param mapView The map view that requested the annotation symbol name.
* @param annotation The object representing the annotation that is about to be displayed.
* @return The marker symbol to display for the specified annotation or `nil` if you want to display the default symbol. */
-- (NSString *)mapView:(MGLMapView *)mapView symbolNameForAnnotation:(id <MGLAnnotation>)annotation;
+- (nullable NSString *)mapView:(MGLMapView *)mapView symbolNameForAnnotation:(id <MGLAnnotation>)annotation;
/** Returns a Boolean value indicating whether the annotation is able to display extra information in a callout bubble.
*
@@ -322,7 +324,7 @@ IB_DESIGNABLE
* @param mapView The map view presenting the annotation callout.
* @param annotation The object representing the annotation with the callout.
* @return The accessory view to display. */
-- (UIView *)mapView:(MGLMapView *)mapView leftCalloutAccessoryViewForAnnotation:(id <MGLAnnotation>)annotation;
+- (nullable UIView *)mapView:(MGLMapView *)mapView leftCalloutAccessoryViewForAnnotation:(id <MGLAnnotation>)annotation;
/** Return the view to display on the right side of the standard callout bubble.
*
@@ -333,7 +335,7 @@ IB_DESIGNABLE
* @param mapView The map view presenting the annotation callout.
* @param annotation The object representing the annotation with the callout.
* @return The accessory view to display. */
-- (UIView *)mapView:(MGLMapView *)mapView rightCalloutAccessoryViewForAnnotation:(id <MGLAnnotation>)annotation;
+- (nullable UIView *)mapView:(MGLMapView *)mapView rightCalloutAccessoryViewForAnnotation:(id <MGLAnnotation>)annotation;
#pragma mark - Responding to Map Position Changes
@@ -391,7 +393,7 @@ IB_DESIGNABLE
*
* @param mapView The map view that is tracking the user’s location.
* @param userLocation The location object representing the user’s latest location. This property may be `nil`. */
-- (void)mapView:(MGLMapView *)mapView didUpdateUserLocation:(MGLUserLocation *)userLocation;
+- (void)mapView:(MGLMapView *)mapView didUpdateUserLocation:(nullable MGLUserLocation *)userLocation;
/** Tells the delegate that an attempt to locate the user’s position failed.
* @param mapView The map view that is tracking the user’s location.
@@ -443,3 +445,5 @@ IB_DESIGNABLE
- (void)mapView:(MGLMapView *)mapView didDeselectAnnotation:(id <MGLAnnotation>)annotation;
@end
+
+NS_ASSUME_NONNULL_END
diff --git a/include/mbgl/ios/MGLTypes.h b/include/mbgl/ios/MGLTypes.h
index d4bc6c2ce2..a4fe707802 100644
--- a/include/mbgl/ios/MGLTypes.h
+++ b/include/mbgl/ios/MGLTypes.h
@@ -1,5 +1,7 @@
#import <Foundation/Foundation.h>
+NS_ASSUME_NONNULL_BEGIN
+
extern NSString * const MGLErrorDomain;
/** The mode used to track the user location on the map. */
@@ -12,3 +14,5 @@ typedef NS_ENUM(NSUInteger, MGLUserTrackingMode)
/** The map follows the user location and rotates when the heading changes. */
MGLUserTrackingModeFollowWithHeading
};
+
+NS_ASSUME_NONNULL_END
diff --git a/include/mbgl/ios/MGLUserLocation.h b/include/mbgl/ios/MGLUserLocation.h
index 1bff512223..2eea515908 100644
--- a/include/mbgl/ios/MGLUserLocation.h
+++ b/include/mbgl/ios/MGLUserLocation.h
@@ -1,5 +1,7 @@
#import "MGLAnnotation.h"
+NS_ASSUME_NONNULL_BEGIN
+
/** The MGLUserLocation class defines a specific type of annotation that identifies the user’s current location. You do not create instances of this class directly. Instead, you retrieve an existing MGLUserLocation object from the userLocation property of the map view displayed in your application. */
@interface MGLUserLocation : NSObject <MGLAnnotation>
@@ -8,7 +10,7 @@
/** The current location of the device. (read-only)
*
* This property contains `nil` if the map view is not currently showing the user location or if the user’s location has not yet been determined. */
-@property (nonatomic, readonly) CLLocation *location;
+@property (nonatomic, readonly, nullable) CLLocation *location;
/** A Boolean value indicating whether the user’s location is currently being updated. (read-only) */
@property (nonatomic, readonly, getter=isUpdating) BOOL updating;
@@ -16,7 +18,7 @@
/** The heading of the user location. (read-only)
*
* This property is `nil` if the user location tracking mode is not `MGLUserTrackingModeFollowWithHeading`. */
-@property (nonatomic, readonly) CLHeading *heading;
+@property (nonatomic, readonly, nullable) CLHeading *heading;
/** @name Accessing the User Annotation Text */
@@ -24,6 +26,8 @@
@property (nonatomic, copy) NSString *title;
/** The subtitle to display for the user location annotation. */
-@property (nonatomic, copy) NSString *subtitle;
+@property (nonatomic, copy, nullable) NSString *subtitle;
@end
+
+NS_ASSUME_NONNULL_END