我有一个在字符串长度上运行的 for 循环。第一个循环查找第二个循环中常见的字符。我想保存数组或字符串中常见的 nameString 的索引。请帮忙。代码在下面提到。
for (int i=0; i < nameString.length; i++) {
char currentLetter = [nameString characterAtIndex:i];
for (int j=0; j < partnersNameString.length; j++) {
if (currentLetter == [partnersNameString characterAtIndex:j]) {
NSRange range;
range.length=1;
range.location=j;
[partnersNameString replaceCharactersInRange:range withString:@""];
calculateField.text = partnersNameString;
}
}
}