Skip to content

Instantly share code, notes, and snippets.

@kwylez
Created December 27, 2010 04:29
Show Gist options
  • Save kwylez/755860 to your computer and use it in GitHub Desktop.
Save kwylez/755860 to your computer and use it in GitHub Desktop.
- (BOOL)isEqual:(id)other {
if (other == self)
return YES;
if (!other || ![other isKindOfClass:[self class]])
return NO;
return [self isEqualToWidget:other];
}
- (BOOL)isEqualToWidget:(MyWidget *)aWidget {
if (self == aWidget)
return YES;
if (![(id)[self name] isEqual:[aWidget name]])
return NO;
if (![[self data] isEqualToData:[aWidget data]])
return NO;
return YES;
}
- (NSUInteger)hash {
NSUInteger hash = 0;
hash += [[self name] hash];
hash += [[self data] hash];
return hash;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment