Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[ios] override hash
Browse files Browse the repository at this point in the history
  • Loading branch information
frederoni committed Oct 4, 2016
1 parent 9e17fd8 commit 139b6d9
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions platform/darwin/src/MGLPointAnnotation.m
Expand Up @@ -27,14 +27,14 @@ - (void)encodeWithCoder:(NSCoder *)coder

- (BOOL)isEqual:(id)other
{
if ( ! [other isKindOfClass:[self class]])
{
return NO;
}
if (other == self)
{
return YES;
}
if ( ! [other isKindOfClass:[self class]])
{
return NO;
}

MGLPointAnnotation *otherAnnotation = other;
return (self.coordinate.latitude == otherAnnotation.coordinate.latitude
Expand All @@ -43,6 +43,12 @@ - (BOOL)isEqual:(id)other
&& [self.subtitle isEqualToString:otherAnnotation.subtitle]);
}

- (NSUInteger)hash
{
return @(self.coordinate.latitude).hash+@(self.coordinate.longitude).hash
+self.title.hash+self.subtitle.hash;
}

- (NSString *)description
{
return [NSString stringWithFormat:@"<%@: %p; title = %@; subtitle = %@; coordinate = %f, %f>",
Expand Down

0 comments on commit 139b6d9

Please sign in to comment.