/* NSArray.h Copyright (c) 1994-2012, Apple Inc. All rights reserved. */ #import #import #import #import @class NSData, NSIndexSet, NSString, NSURL; /**************** Immutable Array ****************/ @interface NSArray : NSObject - (NSUInteger)count; - (id)objectAtIndex:(NSUInteger)index; @end @interface NSArray (NSExtendedArray) - (NSArray *)arrayByAddingObject:(id)anObject; - (NSArray *)arrayByAddingObjectsFromArray:(NSArray *)otherArray; - (NSString *)componentsJoinedByString:(NSString *)separator; - (BOOL)containsObject:(id)anObject; - (NSString *)description; - (NSString *)descriptionWithLocale:(id)locale; - (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level; - (id)firstObjectCommonWithArray:(NSArray *)otherArray; - (void)getObjects:(id __unsafe_unretained [])objects range:(NSRange)range; - (NSUInteger)indexOfObject:(id)anObject; - (NSUInteger)indexOfObject:(id)anObject inRange:(NSRange)range; - (NSUInteger)indexOfObjectIdenticalTo:(id)anObject; - (NSUInteger)indexOfObjectIdenticalTo:(id)anObject inRange:(NSRange)range; - (BOOL)isEqualToArray:(NSArray *)otherArray; - (id)lastObject; - (NSEnumerator *)objectEnumerator; - (NSEnumerator *)reverseObjectEnumerator; - (NSData *)sortedArrayHint; - (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void *))comparator context:(void *)context; - (NSArray *)sortedArrayUsingFunction:(NSInteger (*)(id, id, void *))comparator context:(void *)context hint:(NSData *)hint; - (NSArray *)sortedArrayUsingSelector:(SEL)comparator; - (NSArray *)subarrayWithRange:(NSRange)range; - (BOOL)writeToFile:(NSString *)path atomically:(BOOL)useAuxiliaryFile; - (BOOL)writeToURL:(NSURL *)url atomically:(BOOL)atomically; - (void)makeObjectsPerformSelector:(SEL)aSelector; - (void)makeObjectsPerformSelector:(SEL)aSelector withObject:(id)argument; - (NSArray *)objectsAtIndexes:(NSIndexSet *)indexes; - (id)objectAtIndexedSubscript:(NSUInteger)idx NS_AVAILABLE(10_8, 6_0); #if NS_BLOCKS_AVAILABLE - (void)enumerateObjectsUsingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block NS_AVAILABLE(10_6, 4_0); - (void)enumerateObjectsWithOptions:(NSEnumerationOptions)opts usingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block NS_AVAILABLE(10_6, 4_0); - (void)enumerateObjectsAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts usingBlock:(void (^)(id obj, NSUInteger idx, BOOL *stop))block NS_AVAILABLE(10_6, 4_0); - (NSUInteger)indexOfObjectPassingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate NS_AVAILABLE(10_6, 4_0); - (NSUInteger)indexOfObjectWithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate NS_AVAILABLE(10_6, 4_0); - (NSUInteger)indexOfObjectAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate NS_AVAILABLE(10_6, 4_0); - (NSIndexSet *)indexesOfObjectsPassingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate NS_AVAILABLE(10_6, 4_0); - (NSIndexSet *)indexesOfObjectsWithOptions:(NSEnumerationOptions)opts passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate NS_AVAILABLE(10_6, 4_0); - (NSIndexSet *)indexesOfObjectsAtIndexes:(NSIndexSet *)s options:(NSEnumerationOptions)opts passingTest:(BOOL (^)(id obj, NSUInteger idx, BOOL *stop))predicate NS_AVAILABLE(10_6, 4_0); - (NSArray *)sortedArrayUsingComparator:(NSComparator)cmptr NS_AVAILABLE(10_6, 4_0); - (NSArray *)sortedArrayWithOptions:(NSSortOptions)opts usingComparator:(NSComparator)cmptr NS_AVAILABLE(10_6, 4_0); typedef NS_OPTIONS(NSUInteger, NSBinarySearchingOptions) { NSBinarySearchingFirstEqual = (1UL << 8), NSBinarySearchingLastEqual = (1UL << 9), NSBinarySearchingInsertionIndex = (1UL << 10), }; - (NSUInteger)indexOfObject:(id)obj inSortedRange:(NSRange)r options:(NSBinarySearchingOptions)opts usingComparator:(NSComparator)cmp NS_AVAILABLE(10_6, 4_0); // binary search #endif @end @interface NSArray (NSArrayCreation) + (id)array; + (id)arrayWithObject:(id)anObject; + (id)arrayWithObjects:(const id [])objects count:(NSUInteger)cnt; + (id)arrayWithObjects:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATION; + (id)arrayWithArray:(NSArray *)array; - (id)initWithObjects:(const id [])objects count:(NSUInteger)cnt; - (id)initWithObjects:(id)firstObj, ... NS_REQUIRES_NIL_TERMINATION; - (id)initWithArray:(NSArray *)array; - (id)initWithArray:(NSArray *)array copyItems:(BOOL)flag; + (id)arrayWithContentsOfFile:(NSString *)path; + (id)arrayWithContentsOfURL:(NSURL *)url; - (id)initWithContentsOfFile:(NSString *)path; - (id)initWithContentsOfURL:(NSURL *)url; @end @interface NSArray (NSDeprecated) /* This method is unsafe because it could potentially cause buffer overruns. You should use -getObjects:range: instead. */ - (void)getObjects:(id __unsafe_unretained [])objects; @end /**************** Mutable Array ****************/ @interface NSMutableArray : NSArray - (void)addObject:(id)anObject; - (void)insertObject:(id)anObject atIndex:(NSUInteger)index; - (void)removeLastObject; - (void)removeObjectAtIndex:(NSUInteger)index; - (void)replaceObjectAtIndex:(NSUInteger)index withObject:(id)anObject; @end @interface NSMutableArray (NSExtendedMutableArray) - (void)addObjectsFromArray:(NSArray *)otherArray; - (void)exchangeObjectAtIndex:(NSUInteger)idx1 withObjectAtIndex:(NSUInteger)idx2; - (void)removeAllObjects; - (void)removeObject:(id)anObject inRange:(NSRange)range; - (void)removeObject:(id)anObject; - (void)removeObjectIdenticalTo:(id)anObject inRange:(NSRange)range; - (void)removeObjectIdenticalTo:(id)anObject; - (void)removeObjectsFromIndices:(NSUInteger *)indices numIndices:(NSUInteger)cnt NS_DEPRECATED(10_0, 10_6, 2_0, 4_0); - (void)removeObjectsInArray:(NSArray *)otherArray; - (void)removeObjectsInRange:(NSRange)range; - (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray *)otherArray range:(NSRange)otherRange; - (void)replaceObjectsInRange:(NSRange)range withObjectsFromArray:(NSArray *)otherArray; - (void)setArray:(NSArray *)otherArray; - (void)sortUsingFunction:(NSInteger (*)(id, id, void *))compare context:(void *)context; - (void)sortUsingSelector:(SEL)comparator; - (void)insertObjects:(NSArray *)objects atIndexes:(NSIndexSet *)indexes; - (void)removeObjectsAtIndexes:(NSIndexSet *)indexes; - (void)replaceObjectsAtIndexes:(NSIndexSet *)indexes withObjects:(NSArray *)objects; - (void)setObject:(id)obj atIndexedSubscript:(NSUInteger)idx NS_AVAILABLE(10_8, 6_0); #if NS_BLOCKS_AVAILABLE - (void)sortUsingComparator:(NSComparator)cmptr NS_AVAILABLE(10_6, 4_0); - (void)sortWithOptions:(NSSortOptions)opts usingComparator:(NSComparator)cmptr NS_AVAILABLE(10_6, 4_0); #endif @end @interface NSMutableArray (NSMutableArrayCreation) + (id)arrayWithCapacity:(NSUInteger)numItems; - (id)initWithCapacity:(NSUInteger)numItems; @end