How to turn an NSArray of strings into an array of unique strings, in the same order?
If you have an NSArray of strings { @"ONE", @"ONE", @"ONE", "TWO", @"THREE", @"THREE" } How would I turn that into { @"ONE", @"TWO", @"THREE" } ..where the array follows the same order as the original. I think that you can turn an array into an NSSet to get unique items, but if you turn it back into an array you are not guaranteed to get the same order.. My initial thought was that you could do: NSArray * a = [NSArray arrayWithObjects:@"ONE", @"ONE", @"ONE", @"TWO", @"THREE", @"THREE", nil]; NSLog(@"%@", [a valueForKeyPath:@"@distinctUnionOfObjects.self"]); But that does not maintain order.