By including the .h
and .m
files in this Gist, you can register a listener to numerous notifications on a notification emitter with a single call, providing a dictionary where the keys are the notification names, and the value are @selectors
. Since you cannot directly put a @selector
into a container, a macro is provided to turn the selector into an NSString
.
Now you can do this:
[self.clusterLayer registerListener:self forNotifications:@{
AGSClusterLayerDataLoadingProgressNotification: strSelector(dataLoadProgress:),
AGSClusterLayerDataLoadingErrorNotification: strSelector(dataLoadError:),
AGSClusterLayerClusteringProgressNotification: strSelector(clusteringProgress:)
}];
instead of this:
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(dataLoadProgress:)
name:AGSClusterLayerDataLoadingProgressNotification
object:self.clusterLayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(dataLoadError:)
name:AGSClusterLayerDataLoadingErrorNotification
object:self.clusterLayer];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(clusteringProgress:)
name:AGSClusterLayerClusteringProgressNotification
object:self.clusterLayer];