嗨,我有 2 个标签 textview 和 labelsText,在这种方法中它们是 string1 和 string2,但我真的无法让 textview string1 和 labelsText string2 工作
这是代码:
-(void)findEqualsIn:(NSString *)string1 and:(NSString *)string2 {
NSMutableArray *string1chars = [[NSMutableArray alloc] init];
NSMutableArray *string2chars = [[NSMutableArray alloc] init];
//filling the string1chars array
for (int i = 0; i < [string1 length]; i++) {
[string1chars addObject:[NSString stringWithFormat:@"%c", [string1 characterAtIndex:i]]];
}
//filling the string2chars array
for (int i = 0; i < [string2 length]; i++) {
[string2chars addObject:[NSString stringWithFormat:@"%c", [string2 characterAtIndex:i]]];
}
//checking if they have some letters in common on the same spot
for (int i = 0; i < [string1chars count] && i < [string2chars count]; i++) {
if ([[string1chars objectAtIndex:i] isEqualToString:[string2chars objectAtIndex:i]]) {
//change the color of the character at index i to green
} else {
//change the color of the character at index i to the standard color
}
}