Showing posts with label NSArray. Show all posts
Showing posts with label NSArray. Show all posts

Thursday, November 1, 2012

Remove Duplicate Values from NSMutableArray iPhone

Remove Duplicate Values from NSMutableArray iPhone

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