From 2fbc7b0942038a27d49c99db761fedad8d5bdf52 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Thu, 25 Feb 2016 10:32:13 -0800 Subject: [PATCH 1/2] Make ASMapNode vend its annotations --- AsyncDisplayKit/ASMapNode.h | 5 ++--- AsyncDisplayKit/ASMapNode.mm | 11 +++++++++++ 2 files changed, 13 insertions(+), 3 deletions(-) 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..ab85e4acd3 100644 --- a/AsyncDisplayKit/ASMapNode.mm +++ b/AsyncDisplayKit/ASMapNode.mm @@ -43,6 +43,7 @@ _needsMapReloadOnBoundsChange = YES; _liveMap = NO; _centerCoordinateOfMap = kCLLocationCoordinate2DInvalid; + _annotations = @[]; return self; } @@ -251,8 +252,18 @@ _mapView = nil; } +- (NSArray *)annotations +{ + ASDN::MutexLocker l(_propertyLock); + return _annotations; +} + - (void)setAnnotations:(NSArray *)annotations { + if (annotations == nil) { + annotations = @[]; + } + ASDN::MutexLocker l(_propertyLock); _annotations = [annotations copy]; if (self.isLiveMap) { From 60f5ba2d1781815236b5f2a695ddca9979c99ff7 Mon Sep 17 00:00:00 2001 From: Adlai Holler Date: Thu, 25 Feb 2016 10:40:38 -0800 Subject: [PATCH 2/2] Simplify ASMapNode.setAnnotations --- AsyncDisplayKit/ASMapNode.mm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/AsyncDisplayKit/ASMapNode.mm b/AsyncDisplayKit/ASMapNode.mm index ab85e4acd3..e7ec4cab2b 100644 --- a/AsyncDisplayKit/ASMapNode.mm +++ b/AsyncDisplayKit/ASMapNode.mm @@ -260,12 +260,10 @@ - (void)setAnnotations:(NSArray *)annotations { - if (annotations == nil) { - annotations = @[]; - } + annotations = [annotations copy] ?: @[]; ASDN::MutexLocker l(_propertyLock); - _annotations = [annotations copy]; + _annotations = annotations; if (self.isLiveMap) { [_mapView removeAnnotations:_mapView.annotations]; [_mapView addAnnotations:annotations];