Guest User

Untitled

a guest
Jan 16th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. NSString *compareableString = @“This is a String”;
  2. NSString *comparedString = @“This is a String”;
  3. BOOL *isEqual = (*comparableString == *comparedString);
  4. // this will return NO because it refers to two different objects
  5. /*
  6. So we have to use equality methods from their objects to compare them.
  7. If we want to use our custom equality functions
  8. we also should be sure that the function checks for the pointer equality as a first step of equality function.*/
  9. if(self == object) return YES;
  10. //we also should be sure to have a hash function to check the second equality step.
  11. -(NSUInteger)hash{
  12. NSUInteger *firstNameHash = [_firstName hash];
  13. NSUInteger *lastNameHash = [_firstName hash];
  14. NSUInteger *ageHash = [_firstName hash];
  15. return firstNameHash ^ lastNameHash ^ ageHash;
  16. }
Add Comment
Please, Sign In to add comment