diff --git a/AsyncDisplayKit/ASMapNode.h b/AsyncDisplayKit/ASMapNode.h index 8703ac2c1a..201ef2170f 100644 --- a/AsyncDisplayKit/ASMapNode.h +++ b/AsyncDisplayKit/ASMapNode.h @@ -48,10 +48,9 @@ NS_ASSUME_NONNULL_BEGIN @property (nonatomic, weak) id mapDelegate; /** - * @discussion This method sets the annotations of the static map view and also to the live map view. Passing an empty array clears the map of any annotations. - * @param annotations An array of objects that conform to the MKAnnotation protocol + * @abstract The annotations to display on the map. */ -- (void)setAnnotations:(NSArray> *)annotations; +@property (nonatomic, copy) NSArray> *annotations; @end diff --git a/AsyncDisplayKit/ASMapNode.mm b/AsyncDisplayKit/ASMapNode.mm index c2af85c2e7..e7ec4cab2b 100644 --- a/AsyncDisplayKit/ASMapNode.mm +++ b/AsyncDisplayKit/ASMapNode.mm @@ -43,6 +43,7 @@ _needsMapReloadOnBoundsChange = YES; _liveMap = NO; _centerCoordinateOfMap = kCLLocationCoordinate2DInvalid; + _annotations = @[]; return self; } @@ -251,10 +252,18 @@ _mapView = nil; } -- (void)setAnnotations:(NSArray *)annotations +- (NSArray *)annotations { ASDN::MutexLocker l(_propertyLock); - _annotations = [annotations copy]; + return _annotations; +} + +- (void)setAnnotations:(NSArray *)annotations +{ + annotations = [annotations copy] ?: @[]; + + ASDN::MutexLocker l(_propertyLock); + _annotations = annotations; if (self.isLiveMap) { [_mapView removeAnnotations:_mapView.annotations]; [_mapView addAnnotations:annotations];