Fastest way to check if an array contains the same objects of another array

后端 未结 10 1920
夕颜
夕颜 2020-12-29 04:36

The goal is to compare two arrays as and check if they contain the same objects (as fast as possible - there are lots of objects in the arrays). The arrays cannot be checked

10条回答
  •  悲哀的现实
    2020-12-29 05:27

    I know it's late but i just wanna share what i did..

    NSString *stringArr1 = [NSString stringWithFormat:@"%@", array1];
    NSString *stringArr2 = [NSString stringWithFormat:@"%@", array2];
    
    if ([stringArr1 isEqual: stringArr2])
        NSLog(@"identical");
    else
        NSLog(@"not");
    

    this is just like comparing "@[@1,@2,@3,@4]" == "[@3,@2,@1,@4]".. which is obviously false..

提交回复
热议问题