Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert NSMutableArray to a NSSet with the same order

How can I do that programatically?

I am told that this is the way to do it but the NSSet has a different order.

NSSet *set = [NSSet setWithArray:theArray];

Any idea?

Thanks in advance.

like image 790
maej90 Avatar asked Jul 18 '13 18:07

maej90


2 Answers

If you want order, you'll have to use an NSOrderedSet.

NSOrderedSet *set = [NSOrderedSet orderedSetWithArray:theArray];
like image 112
rdelmar Avatar answered Sep 28 '22 15:09

rdelmar


If you care about the order, you probably do not want to use an NSSet.

like image 22
gsach Avatar answered Sep 28 '22 15:09

gsach