How to Find Duplicate Values in Arrays?

前端 未结 3 1702
栀梦
栀梦 2021-01-13 02:36

I am working on SQLite and I have written a query which returns me two arrays ItemsArray and CustomersIDArray as:

ItemsArray
Element at Index 0 = Off White,
         


        
3条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-01-13 03:28

    try this:

    NSArray *copy = [ItemsArray copy];
    
    NSInteger index = [copy count] - 1;
    
    for (id object in [copy reverseObjectEnumerator]) {
    
        if ([ItemsArray indexOfObject:object inRange:NSMakeRange(0, index)] != NSNotFound) {
            [ItemsArray removeObjectAtIndex:index];
        }
        index--;
    }
    

提交回复
热议问题