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 Dec 8, 2016
1 parent b3875e9 commit 1530ef5
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions platform/darwin/src/MGLPointAnnotation.mm
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,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 @@ -48,6 +48,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 1530ef5

Please sign in to comment.