- (NSUInteger)count;
获取NSArray中对象的个数
- (id)objectAtIndex:(NSUInteger)index;
获取NSArray中index位置的对象
- (NSArray *)arrayByAddingObject:(id)anObject;
把anObject添加到数组的末尾
- (NSArray *)arrayByAddingObjectsFromArray:(NSArray *)otherArray;
把otherArray数组中的对象添加盗数组的末尾
- (NSString *)componentsJoinedByString:(NSString *)separator;
把数组中的元素以separator为分割拼接起来组成一个NSString
- (BOOL)containsObject:(id)anObject;
判断anObject是否在数组中
- (NSString *)description;
对数组中对象的描述,可以输出数组中的对象(待进一步确定)
- (NSString *)descriptionWithLocale:(id)locale;
- (NSString *)descriptionWithLocale:(id)locale indent:(NSUInteger)level;
- (id)firstObjectCommonWithArray:(NSArray *)otherArray;
返回NSArray和otherArray中第一个相同的对象
+ (id)arrayWithObjects:(constid [])objects count:(NSUInteger)cnt;
- NSString *string[5];
- string[0] = @"First";
- string[1] = @"Second";
- string[2] = @"Third";
- string[3] = @"Forth";
- NSArray *array = [NSArray arrayWithObjects:string count:3];
- 输出结果:First, Second, Third
- (void)getObjects:(id __unsafe_unretained [])objects range:(NSRange)range;
从数组objects中取出对应NSRange的数据,range中的数据表示从range.location开始到range.length的元素
- NSArray *mArray = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", @"5", @"6", @"7", @"8", @"9", nil];
- id *objects;
- NSRange range = NSMakeRange(2, 3);
- objects = malloc(sizeof(id) * range.length);
- [mArray getObjects:objects range:range];
- for (NSInteger i = 0; i < range.length; i++)
- {
- NSLog(@"objects: %@", objects[i]);
- }
- free(objects);
- (NSUInteger)indexOfObject:(id)anObject inRange:(NSRange)range;
在整个数组中,在range范围内的anObject对象的索引位置
- (NSEnumerator *)objectEnumerator;
顺序获取数组的NSEnumerator
- (NSEnumerator *)reverseObjectEnumerator;
倒序获取数组的NSEnumerator
- NSEnumerator *enumerator = [mArray objectEnumerator];
- id object;
- while((object = [enumerator nextObject]))
- {
- NSLog(@"object:%@",object);
- }