From 00b2e13b64afd7eb0fde1e60db7ca75cafe85469 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Minh=20Nguy=E1=BB=85n?= Date: Thu, 14 May 2015 14:49:26 -0700 Subject: [PATCH] =?UTF-8?q?mapID=20=E2=86=92=20styleID?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Deprecated `-mapID` and `-setMapID:` to accurately reflect the APIs the ID is used for. Marked the property unavailable but reimplemented its getter and setter to assert with helpful messages. Fixes #1500. --- include/mbgl/ios/MGLMapView+IBAdditions.h | 2 +- include/mbgl/ios/MGLMapView.h | 7 +++--- platform/ios/MGLMapView.mm | 26 +++++++++++++---------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/include/mbgl/ios/MGLMapView+IBAdditions.h b/include/mbgl/ios/MGLMapView+IBAdditions.h index df9a19a6b7f..0f1d2b2f8f0 100644 --- a/include/mbgl/ios/MGLMapView+IBAdditions.h +++ b/include/mbgl/ios/MGLMapView+IBAdditions.h @@ -9,7 +9,7 @@ // MGLMapView+IBAdditions.h, due to ASCII sort order. @property (nonatomic) IBInspectable NSString *accessToken; -@property (nonatomic) IBInspectable NSString *mapID; +@property (nonatomic) 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 diff --git a/include/mbgl/ios/MGLMapView.h b/include/mbgl/ios/MGLMapView.h index 9d7b5c9019b..50174e31c28 100644 --- a/include/mbgl/ios/MGLMapView.h +++ b/include/mbgl/ios/MGLMapView.h @@ -162,12 +162,13 @@ IB_DESIGNABLE /** @name Styling the Map */ -/** Mapbox map ID of the style currently displayed in the receiver, or `nil` if the style does not have a map ID. +/** Mapbox ID of the style currently displayed in the receiver, or `nil` if the style does not have an ID. * -* The style may lack a map ID if it is located at an HTTP, HTTPS, or local file URL. Use `styleURL` to get the URL in these cases. +* 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 *mapID; +@property (nonatomic) NSString *styleID; +@property (nonatomic) NSString *mapID __attribute__((unavailable("Use styleID."))); /** Returns the URLs to the styles bundled with the library. */ - (NSArray *)bundledStyleURLs; diff --git a/platform/ios/MGLMapView.mm b/platform/ios/MGLMapView.mm index ff31ec9e1a7..b488d01f617 100644 --- a/platform/ios/MGLMapView.mm +++ b/platform/ios/MGLMapView.mm @@ -162,7 +162,7 @@ - (void)setAccessToken:(NSString *)accessToken + (NSSet *)keyPathsForValuesAffectingStyleURL { - return [NSSet setWithObjects:@"mapID", @"accessToken", nil]; + return [NSSet setWithObjects:@"styleID", @"accessToken", nil]; } - (NSURL *)styleURL @@ -1543,27 +1543,31 @@ - (NSArray *)bundledStyleURLs return [NSArray arrayWithArray:_bundledStyleURLs]; } -+ (NSSet *)keyPathsForValuesAffectingMapID ++ (NSSet *)keyPathsForValuesAffectingStyleID { return [NSSet setWithObjects:@"styleURL", @"accessToken", nil]; } -- (NSString *)mapID +- (NSString *)styleID { NSURL *styleURL = self.styleURL; return [styleURL.scheme isEqualToString:@"mapbox"] ? styleURL.host.mgl_stringOrNilIfEmpty : nil; } +- (void)setStyleID:(NSString *)styleID +{ + self.styleURL = styleID ? [NSURL URLWithString:[NSString stringWithFormat:@"mapbox://%@", styleID]] : nil; +} + +- (NSString *)mapID +{ + NSAssert(NO, @"-[MGLMapView mapID] has been renamed -[MGLMapView styleID]."); + return nil; +} + - (void)setMapID:(NSString *)mapID { - if (mapID) - { - self.styleURL = [NSURL URLWithString:[NSString stringWithFormat:@"mapbox://%@", mapID]]; - } - else - { - self.styleURL = nil; - } + 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