@@ -36,20 +36,23 @@ - (id)init
3636- (void )registerAnnotationViewForClass : (Class <MKAnnotation>)cls annotationView : (NSString *)annotation
3737{
3838 NSParameterAssert (annotation != nil && cls != Nil );
39- if ([NSClassFromString (annotation) isSubclassOfClass: [MKAnnotationView class ]])
39+ if ([NSClassFromString (annotation) isSubclassOfClass: [MKAnnotationView class ]]) {
4040 _annotationViewForClass[NSStringFromClass (cls)] = NSClassFromString (annotation);
41- else
41+ }
42+ else {
4243 [[NSException exceptionWithName: NSInvalidArgumentException
4344 reason: [NSString stringWithFormat: @" Annotation %@ should be any subclass of the MKAnnotationView" , annotation]
4445 userInfo: nil ] raise ];
46+ }
4547}
4648
4749- (void )registerAnnotationViewForClass : (Class <MKAnnotation>)cls annotationView : (NSString *)annotation
4850 configBlock : (void (^)(MKAnnotationView *, id <MKAnnotation>))block
4951{
5052 [self registerAnnotationViewForClass: cls annotationView: annotation];
51- if (block)
53+ if (block) {
5254 [self setConfigBlockForClass: cls block: block];
55+ }
5356}
5457
5558- (void )setConfigBlockForClass : (Class <MKAnnotation>)cls block : (ConfigurationBlockType)block
@@ -84,19 +87,21 @@ - (void)registerAnnotationViewForClass:(Class <MKAnnotation>)cls translationBloc
8487 }
8588}
8689
87-
8890- (MKAnnotationView *)mapView : (MKMapView *)mapView viewForAnnotation : (id <MKAnnotation>)annotation
8991{
9092
9193 if ([annotation class ] == [MKUserLocation class ]) return _userLocationAnnotationView;
9294
93- if ([self HK_isNoneRegistered ])
94- return _defaultAnnotationView;
95-
95+ if ([self HK_isNoneRegistered ]) {
96+ return _defaultAnnotationView;
97+ }
98+
9699 MKAnnotationView* annotationView;
97100 NSString *reuseIdentifier = [self HK_reuseIdentifierForAnnotation: annotation];
98101
99- if (!reuseIdentifier) return _defaultAnnotationView;
102+ if (![reuseIdentifier length ]) {
103+ return _defaultAnnotationView;
104+ }
100105
101106 if ( !(annotationView = [mapView dequeueReusableAnnotationViewWithIdentifier: reuseIdentifier]) ) {
102107 Class c = [self HK_annotationViewClassFromAnnotation: annotation];
@@ -113,35 +118,42 @@ - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnot
113118
114119- (NSString *)HK_reuseIdentifierForAnnotation : (id <MKAnnotation>)annotation
115120{
116- if (_translationBlockForAllClasses && _translationBlockForAllClasses (annotation))
121+ if (_translationBlockForAllClasses && _translationBlockForAllClasses (annotation)) {
117122 return _translationBlockForAllClasses (annotation);
123+ }
118124
119125 NSString *annotationViewClass = NSStringFromClass ([annotation class ]);
120126
121- if (_translationBlockForClass[annotationViewClass] && ((TranslationBlockType) _translationBlockForClass[annotationViewClass]) (annotation) )
127+ if (_translationBlockForClass[annotationViewClass] && ((TranslationBlockType) _translationBlockForClass[annotationViewClass]) (annotation) ) {
122128 return ((TranslationBlockType) _translationBlockForClass[annotationViewClass]) (annotation);
123- else
129+ }
130+ else {
124131 return NSStringFromClass (_annotationViewForClass[annotationViewClass]);
132+ }
125133}
126134
127135- (Class )HK_annotationViewClassFromAnnotation : (id <MKAnnotation>)annotation
128136{
129137 Class annotationViewClass = NSClassFromString ([self HK_reuseIdentifierForAnnotation: annotation]);
130138
131- if (! [annotationViewClass isSubclassOfClass: [MKAnnotationView class ]] )
139+ if (! [annotationViewClass isSubclassOfClass: [MKAnnotationView class ]] ) {
132140 [[NSException exceptionWithName: NSInvalidArgumentException
133141 reason: [NSString stringWithFormat: @" %@ should be any subclass of the MKAnnotationView" , annotationViewClass]
134142 userInfo: nil ] raise ];
143+ }
135144
136145 return annotationViewClass;
137146}
138147
139148- (void )HK_configureAnnotationView : (MKAnnotationView *)annotationView
140149{
141- if ( _configBlockForAnnotationView[ NSStringFromClass ([annotationView.annotation class ])] )
150+ if ( _configBlockForAnnotationView[ NSStringFromClass ([annotationView.annotation class ])] ) {
142151 ( (ConfigurationBlockType)_configBlockForAnnotationView[ NSStringFromClass ([annotationView.annotation class ]) ] )(annotationView, annotationView.annotation );
143- if (_configBlockForAllClasses)
144- _configBlockForAllClasses (annotationView, annotationView.annotation );
152+ }
153+
154+ if (_configBlockForAllClasses) {
155+ _configBlockForAllClasses (annotationView, annotationView.annotation );
156+ }
145157}
146158
147159- (BOOL )HK_isNoneRegistered
0 commit comments