[ios] fix #6361: source query nullability & return nil for unfound results (#6408)

Also removes some dead code in MGLStyle.mm.
This commit is contained in:
Justin R. Miller
2016-09-21 10:59:45 -07:00
committed by GitHub
parent f4ba92af1f
commit 2bde64fcb3
2 changed files with 5 additions and 11 deletions

View File

@@ -187,7 +187,7 @@ static const NSInteger MGLStyleDefaultVersion = 9;
@return source An instance of an `MGLSource` subclass.
*/
- (MGLSource *)sourceWithIdentifier:(NSString *)identifier;
- (nullable MGLSource *)sourceWithIdentifier:(NSString *)identifier;
/**
Adds a new layer on top of existing layers.

View File

@@ -92,19 +92,11 @@ static NSURL *MGLStyleURL_emerald;
return @(self.mapView.mbglMap->getStyleName().c_str());
}
- (mbgl::style::Layer *)mbglLayerWithIdentifier:(NSString *)identifier
{
return self.mapView.mbglMap->getLayer(identifier.UTF8String);
}
- (mbgl::style::Source *)mbglSourceWithIdentifier:(NSString *)identifier
{
return self.mapView.mbglMap->getSource(identifier.UTF8String);
}
- (id <MGLStyleLayer>)layerWithIdentifier:(NSString *)identifier
{
auto layer = self.mapView.mbglMap->getLayer(identifier.UTF8String);
if (!layer) return nil;
Class clazz = [self classFromLayer:layer];
@@ -119,6 +111,8 @@ static NSURL *MGLStyleURL_emerald;
- (MGLSource *)sourceWithIdentifier:(NSString *)identifier
{
auto s = self.mapView.mbglMap->getSource(identifier.UTF8String);
if (!s) return nil;
Class clazz = [self classFromSource:s];