2个数组对象是否相等?

are 2 array objects equal?

我正在尝试查找 paket2 是否包含 paket1 中的任何对象。我试过这段代码:

//assume paket1 and paket2 are 2 NSArrays
            int n;
            int m;
            for (n=0; n<[paket1 count]; n++) {
                for (m=0; m<[paket2 count]; m++) {
                    if (paket1[n]==paket2[m] ) {
                        NSLog(@"some message");
                    }else{
                        NSLog(@"bruhuhuhu");
                    }
                }
            }

但我觉得 == 运算符只是检查 2 个内存地址是否相等。我想检查数组对象的值。你们能指导我怎么做吗?

假设数组中的对象实现了isEqual:方法:

[paket1[n] isEqual:paket2[m]]

使用 isEqual:

        for (int n=0; n<paket1.count; n++) {
            for (int m=0; m<paket2.count;m++) {
                if (paket1[n] isEqual: paket2[m] ) {
                    NSLog(@"some message");
                }else{
                    NSLog(@"bruhuhuhu");
                }
            }
        }