How to compare two NSArrays for equal content?

前端 未结 7 1433
旧巷少年郎
旧巷少年郎 2021-02-13 01:58

I have 2 Nsarray where objects of 2 arrays are same may be indexes of the object differs, but it should print both are equal irrespective of there indexes

NSArra         


        
相关标签:
7条回答
  • 2021-02-13 02:30

    Just like rmaddy said, those NSArrays are not equal. Try this:

    -(BOOL)compareArrayIgnoreIndexes:(NSArray*)arrayOne toArray:(NSArray*)arrayTwo{
        NSSet *setOne=[[NSSet alloc]initWithArray:arrayOne];
        NSSet *setTwo=[[NSSet alloc]initWithArray:arrayTwo];
        return [setOne isEqualToSet:setTwo];
    }
    
    0 讨论(0)
提交回复
热议问题