We divided the task into two parts.
Part 1: Search for differences.
You can do this using the following code,
NSString *string1 = @"My cat sometimes likes to eat fish."; NSString * string2 = @"My cat always likes to drink fresh water, and eat fish."; NSMutableSet *set1 = [NSMutableSet setWithArray:[string1 componentsSeparatedByString:@" "]]; NSMutableSet *set2 = [NSMutableSet setWithArray:[string2 componentsSeparatedByString:@" "]]; [set2 minusSet:set1]; NSLog(@"%@",set2);
Part 2: Highlighting words.
Once you recognize the words, they are easy to distinguish.
source share