解决方法
与Java的集合类相反,Objective-C(或更基础的)数组是完全隐藏其实现的不透明类集群.
编辑:snip(见橙色评论)
虽然Java有大量的收集类,如:
>哈希集
> TreeSet
> LinkedHashSet
> ArrayList
> LinkedList
> PriorityQueue
> HashMap
> TreeMap
> LinkedHashMap
> WeakHashMap
> IdentityHashMap
> CopyOnWriteArrayList
> CopyOnWriteArraySet
> EnumSet
> EnumMap
> ConcurrentLinkedQueue
> LinkedBlockingQueue
> ArrayBlockingQueue
> PriorityBlockingQueue
> DelayQueue
> SynchronousQueue
> ConcurrentHashMap
但是Objective-C(实际上是Foundation SDK)只提供了非常有限数量的集合类:
> CFMutableDictionary
> CFMutableBag
> CFMutableBitVector
> CFMutableSet
> CFMutableArray
> CFBinaryHeap
> CFMutableTree
或优选其NS-等价物:
> NSMutableDictionary
> NSDictionary
> NSMutableSet
> NSSet
> NSCountedSet
> NSMutableArray
> NSArray
对于这个问题的全面了解,我建议这样阅读:
http://ridiculousfish.com/blog/posts/array.html(作者是苹果基金会团队的成员)