diff options
Diffstat (limited to 'platform/darwin/src/MGLPointAnnotation.mm')
-rw-r--r-- | platform/darwin/src/MGLPointAnnotation.mm | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/platform/darwin/src/MGLPointAnnotation.mm b/platform/darwin/src/MGLPointAnnotation.mm index d2e87f07d1..a2108a9e3b 100644 --- a/platform/darwin/src/MGLPointAnnotation.mm +++ b/platform/darwin/src/MGLPointAnnotation.mm @@ -1,6 +1,7 @@ #import "MGLPointAnnotation.h" #import "MGLShape_Private.h" +#import "NSCoder+MGLAdditions.h" #import <mbgl/util/geometry.hpp> @@ -9,6 +10,41 @@ @synthesize coordinate; ++ (BOOL)supportsSecureCoding +{ + return YES; +} + +- (instancetype)initWithCoder:(NSCoder *)coder +{ + if (self = [super initWithCoder:coder]) { + self.coordinate = [coder decodeMGLCoordinateForKey:@"coordinate"]; + } + return self; +} + +- (void)encodeWithCoder:(NSCoder *)coder +{ + [super encodeWithCoder:coder]; + [coder encodeMGLCoordinate:coordinate forKey:@"coordinate"]; +} + +- (BOOL)isEqual:(id)other +{ + if (other == self) return YES; + if (![other isKindOfClass:[MGLPointAnnotation class]]) return NO; + + MGLPointAnnotation *otherAnnotation = other; + return ([super isEqual:other] + && self.coordinate.latitude == otherAnnotation.coordinate.latitude + && self.coordinate.longitude == otherAnnotation.coordinate.longitude); +} + +- (NSUInteger)hash +{ + return [super hash] + @(self.coordinate.latitude).hash + @(self.coordinate.longitude).hash; +} + - (NSString *)description { return [NSString stringWithFormat:@"<%@: %p; title = %@; subtitle = %@; coordinate = %f, %f>", |