我是iOS新手。有人知道NSSet
是否比NSArray
快?为什么我不总是只使用NSArray
?
有人向我解释NSSet
和NSArray
之间的区别吗?
最佳答案
NSSet用于具有唯一对象。
NSArray可能有重复的对象。
NSSet是无序集合。
NSArray是有序集合。
NSArray is faster than NSSet for simply holding and iterating. As little as 50% faster for constructing and as much as 500% faster for iterating. if you only need to iterate contents, don't use an NSSet.
关于ios - NSSet比NSArray快吗?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22679418/