有没有更快的方法来比较 2 个 NSArrays?我需要知道两个数组中是否存在缺口并获取它们的索引。
看看我的方法,我认为我们可以更快地做一些事情
-(void)classPseudo
{
AppDelegate *app = [[UIApplication sharedApplication]delegate];
NSString * documentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
NSString *fullFileName = [NSString stringWithFormat:@"%@/contactArray.txt", documentsPath];
NSMutableArray *newOnlineArray = [[NSMutableArray alloc]initWithContentsOfFile:fullFileName];
NSUInteger count = [newOnlineArray count];
NSUInteger count2 = [app.messagePseudo count];
for (NSUInteger index = 0; index < count; index++)
{
for (NSUInteger index2 = 0; index2 < count2; index2++)
{
dict1= [newOnlineArray objectAtIndex:index];
st1 = [dict1 objectForKey:@"pseudo"];
dict2= [app.messagePseudo objectAtIndex:index2];
st2 = [dict2 objectForKey:@"expediteur"];
if ([st2 isEqualToString:st1])
{
NSLog(@"YESS %d",index);
}
else {
NSLog(@"NOOOON");
}
}
}
}
任何帮助都将提前获得 .Thanx。