赞
踩
今天讲不可变数组 NSArray 可变数组 NSMutableArray。话不多说,直接上干货。
NSMutableArray *muArray = [[NSMutableArray alloc] initWithObjects:@"1", @"2", @"3", nil];
NSMutableArray *muArray = [NSMutableArray arrayWithObjects:@"1", @"2", @"3", nil];
[muArray addObject:@"4"];
[muArray addObjectsFromArray:array];
[muArray removeObject:@"1"];
[muArray removeObjectAtIndex:0];
[muArray removeLastObject];
[muArray removeAllObjects];
[muArray replaceObjectAtIndex:0 withObject:@"0"];
[muArray replaceObjectsInRange:NSMakeRange(0, 1) withObjectsFromArray:@[@"0", @"1"]];
NSArray *array = @[@"1", @"2", @"3", @"4"];
NSArray *array = [[NSArray alloc] initWithObjects:@"1", @"2", @"3", @"4", nil];
NSArray *array = [NSArray arrayWithObjects:@"1", @"2", @"3", @"4", nil];
注意:数组坐标从0开始计算
NSString *value = [array objectAtIndex:0];
NSString *value = array[0];
NSUInteger key = [array indexOfObject:@"1"];
NSInteger count = [array count];
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。