Skip to content
This repository was archived by the owner on Aug 8, 2023. It is now read-only.

Audit headers for nullability #1578

Merged
merged 1 commit into from
Jun 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions include/mbgl/ios/MGLAccountManager.h
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 */

Expand All @@ -27,3 +29,5 @@
+ (BOOL)mapboxMetricsEnabledSettingShownInApp;

@end

NS_ASSUME_NONNULL_END
9 changes: 7 additions & 2 deletions include/mbgl/ios/MGLAnnotation.h
Original file line number Diff line number Diff line change
@@ -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. */
Expand All @@ -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
7 changes: 6 additions & 1 deletion include/mbgl/ios/MGLMapView+IBAdditions.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
#import "MGLMapView.h"
#import "MGLTypes.h"

NS_ASSUME_NONNULL_BEGIN

@interface MGLMapView (IBAdditions)

Expand All @@ -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
Expand All @@ -30,3 +33,5 @@
@property (nonatomic) IBInspectable BOOL showsUserLocation;

@end

NS_ASSUME_NONNULL_END
38 changes: 21 additions & 17 deletions include/mbgl/ios/MGLMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
#import <UIKit/UIKit.h>
#import <CoreLocation/CoreLocation.h>

NS_ASSUME_NONNULL_BEGIN

@class MGLUserLocation;

@protocol MGLMapViewDelegate;
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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.
*
Expand All @@ -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;
Expand All @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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.
*
Expand All @@ -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.
*
Expand All @@ -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

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -443,3 +445,5 @@ IB_DESIGNABLE
- (void)mapView:(MGLMapView *)mapView didDeselectAnnotation:(id <MGLAnnotation>)annotation;

@end

NS_ASSUME_NONNULL_END
4 changes: 4 additions & 0 deletions include/mbgl/ios/MGLTypes.h
Original file line number Diff line number Diff line change
@@ -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. */
Expand All @@ -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
10 changes: 7 additions & 3 deletions include/mbgl/ios/MGLUserLocation.h
Original file line number Diff line number Diff line change
@@ -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>

Expand All @@ -8,22 +10,24 @@
/** 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;

/** 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 */

/** The title to display for the user location annotation. */
@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
2 changes: 0 additions & 2 deletions platform/ios/MGLAccountManager.m
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#import <Foundation/Foundation.h>

#import "MGLAccountManager_Private.h"
#import "MGLMapboxEvents.h"
#import "NSProcessInfo+MGLAdditions.h"
Expand Down
6 changes: 5 additions & 1 deletion platform/ios/MGLFileCache.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
#import <Foundation/Foundation.h>
#import "MGLTypes.h"

#include <mbgl/storage/sqlite_cache.hpp>

NS_ASSUME_NONNULL_BEGIN

@interface MGLFileCache : NSObject

+ (mbgl::SQLiteCache *)obtainSharedCacheWithObject:(NSObject *)object;
+ (void)releaseSharedCacheForObject:(NSObject *)object;

@end

NS_ASSUME_NONNULL_END
Loading