Skip to content

Instantly share code, notes, and snippets.

@kwylez
Created December 27, 2010 04:59
Show Gist options
  • Save kwylez/755876 to your computer and use it in GitHub Desktop.
Save kwylez/755876 to your computer and use it in GitHub Desktop.
/**
* properties are (int) numberOfViews, (int) secondsForRotation, (MyCustomObject) myCustomObject
*/
- (BOOL)isEqualToCustomWidget:(CustomWidget *)aCustomWidget {
if (self == aCustomWidget)
return YES;
if (numberOfViews != [aCustomWidget numberOfViews])
return NO;
if (secondsForRotation != [aCustomWidget secondsForRotation])
return NO;
if (![myCustomObject isEqual:[aCustomWidget myCustomObject]])
return YES;
}
-(BOOL)isEqual:(id)other {
if(other == self)
return YES;
if(!other || ![other isKindOfClass:[self class]])
return NO;
return [self isEqualToCustomWidget:other];
}
- (unsigned)hash {
return numberOfViews ^ secondsForRotation ^ [myCustomObject hash];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment