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

Commit

Permalink
[ios] fix #6361: source query nullability & return nil for unfound re…
Browse files Browse the repository at this point in the history
…sults (#6408)

Also removes some dead code in MGLStyle.mm.
  • Loading branch information
incanus authored Sep 21, 2016
1 parent f4ba92a commit 2bde64f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
2 changes: 1 addition & 1 deletion platform/darwin/src/MGLStyle.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
14 changes: 4 additions & 10 deletions platform/darwin/src/MGLStyle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -92,19 +92,11 @@ - (NSString *)name {
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];

Expand All @@ -119,6 +111,8 @@ - (NSString *)name {
- (MGLSource *)sourceWithIdentifier:(NSString *)identifier
{
auto s = self.mapView.mbglMap->getSource(identifier.UTF8String);

if (!s) return nil;

Class clazz = [self classFromSource:s];

Expand Down

0 comments on commit 2bde64f

Please sign in to comment.