summaryrefslogtreecommitdiff
path: root/platform/macos/src/MGLAnnotationImage.m
diff options
context:
space:
mode:
Diffstat (limited to 'platform/macos/src/MGLAnnotationImage.m')
-rw-r--r--platform/macos/src/MGLAnnotationImage.m41
1 files changed, 41 insertions, 0 deletions
diff --git a/platform/macos/src/MGLAnnotationImage.m b/platform/macos/src/MGLAnnotationImage.m
index 1b545651d2..f9f900344a 100644
--- a/platform/macos/src/MGLAnnotationImage.m
+++ b/platform/macos/src/MGLAnnotationImage.m
@@ -23,4 +23,45 @@
return self;
}
++ (BOOL)supportsSecureCoding {
+ return YES;
+}
+
+- (instancetype)initWithCoder:(NSCoder *)decoder {
+ if (self = [super init]) {
+ _image = [decoder decodeObjectOfClass:[NSImage class] forKey:@"image"];
+ _reuseIdentifier = [decoder decodeObjectOfClass:[NSString class] forKey:@"reuseIdentifier"];
+ _cursor = [decoder decodeObjectOfClass:[NSCursor class] forKey:@"cursor"];
+ _selectable = [decoder decodeBoolForKey:@"selectable"];
+ }
+ return self;
+}
+
+- (void)encodeWithCoder:(NSCoder *)coder {
+ [coder encodeObject:_image forKey:@"image"];
+ [coder encodeObject:_reuseIdentifier forKey:@"reuseIdentifier"];
+ [coder encodeObject:_cursor forKey:@"cursor"];
+ [coder encodeBool:_selectable forKey:@"selectable"];
+}
+
+- (BOOL)isEqual:(id)other {
+ if (self == other) return YES;
+ if (![other isKindOfClass:[MGLAnnotationImage class]]) return NO;
+
+ MGLAnnotationImage *otherAnnotationImage = other;
+
+ return ((!_reuseIdentifier && !otherAnnotationImage.reuseIdentifier) || [_reuseIdentifier isEqualToString:otherAnnotationImage.reuseIdentifier])
+ && _selectable == otherAnnotationImage.selectable
+ && ((!_cursor && !otherAnnotationImage.cursor) || [_cursor isEqual:otherAnnotationImage.cursor])
+ && ((!_image && !otherAnnotationImage.image) || [[_image TIFFRepresentation] isEqualToData:[otherAnnotationImage.image TIFFRepresentation]]);
+}
+
+- (NSUInteger)hash {
+ NSUInteger hash;
+ hash += [_reuseIdentifier hash];
+ hash += _selectable;
+ hash += [_image hash];
+ return hash;
+}
+
@end