When is it better to use an NSSet over an NSArray?

前端 未结 11 1592
-上瘾入骨i
-上瘾入骨i 2020-12-12 10:27

I have used NSSets many times in my apps, but I have never created one myself.

When is it better to use an NSSet as opposed to an NSArray and why?

11条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-12 11:10

    Just to add a bit of it i use set sometimes just to remove duplicates from array like :-

    NSMutableSet *set=[[NSMutableSet alloc]initWithArray:duplicateValueArray]; // will remove all the duplicate values
    

提交回复
热议问题