summaryrefslogtreecommitdiff
path: root/platform/ios/src
diff options
context:
space:
mode:
authorJesse Bounds <jesse@rebounds.net>2017-05-24 21:08:19 -0700
committerGitHub <noreply@github.com>2017-05-24 21:08:19 -0700
commitfce7747da099519d8e29eff4befc5c205048492a (patch)
tree9010c5dd5a49d563b509a745f5376d49649a4192 /platform/ios/src
parente1431f9085153f7afb33ee169289ff46d38fe209 (diff)
downloadqtlocation-mapboxgl-fce7747da099519d8e29eff4befc5c205048492a.tar.gz
[ios] Fix annotation initializers for subclasses of MGLAnnotationView (#9104)
Use a common init function in both of the provided initializers so that subclasses of `MGLAnnotationView` written in Swift don't need to override `init(annotation, reuseIdentifier)`
Diffstat (limited to 'platform/ios/src')
-rw-r--r--platform/ios/src/MGLAnnotationView.mm23
1 files changed, 15 insertions, 8 deletions
diff --git a/platform/ios/src/MGLAnnotationView.mm b/platform/ios/src/MGLAnnotationView.mm
index 9e1212b4fb..78e38f10cb 100644
--- a/platform/ios/src/MGLAnnotationView.mm
+++ b/platform/ios/src/MGLAnnotationView.mm
@@ -24,22 +24,29 @@
}
- (instancetype)initWithReuseIdentifier:(NSString *)reuseIdentifier {
- return [self initWithAnnotation:nil reuseIdentifier:reuseIdentifier];
+ self = [super initWithFrame:CGRectZero];
+ if (self) {
+ [self commonInitWithAnnotation:nil reuseIdentifier:reuseIdentifier];
+ }
+ return self;
}
- (instancetype)initWithAnnotation:(nullable id<MGLAnnotation>)annotation reuseIdentifier:(nullable NSString *)reuseIdentifier {
self = [super initWithFrame:CGRectZero];
- if (self)
- {
- _lastAppliedScaleTransform = CATransform3DIdentity;
- _annotation = annotation;
- _reuseIdentifier = [reuseIdentifier copy];
- _scalesWithViewingDistance = YES;
- _enabled = YES;
+ if (self) {
+ [self commonInitWithAnnotation:annotation reuseIdentifier:reuseIdentifier];
}
return self;
}
+- (void)commonInitWithAnnotation:(nullable id<MGLAnnotation>)annotation reuseIdentifier:(nullable NSString *)reuseIdentifier {
+ _lastAppliedScaleTransform = CATransform3DIdentity;
+ _annotation = annotation;
+ _reuseIdentifier = [reuseIdentifier copy];
+ _scalesWithViewingDistance = YES;
+ _enabled = YES;
+}
+
- (instancetype)initWithCoder:(NSCoder *)decoder {
if (self = [super initWithCoder:decoder]) {
_reuseIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"reuseIdentifier"];