Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- NSString *compareableString = @“This is a String”;
- NSString *comparedString = @“This is a String”;
- BOOL *isEqual = (*comparableString == *comparedString);
- // this will return NO because it refers to two different objects
- /*
- So we have to use equality methods from their objects to compare them.
- If we want to use our custom equality functions
- we also should be sure that the function checks for the pointer equality as a first step of equality function.*/
- if(self == object) return YES;
- //we also should be sure to have a hash function to check the second equality step.
- -(NSUInteger)hash{
- NSUInteger *firstNameHash = [_firstName hash];
- NSUInteger *lastNameHash = [_firstName hash];
- NSUInteger *ageHash = [_firstName hash];
- return firstNameHash ^ lastNameHash ^ ageHash;
- }
Add Comment
Please, Sign In to add comment