objective-c 可变数组的操作

 //可变数组

NSMutableArray *ma = [NSMutableArray arrayWithCapacity:7];

[ma addObject: @"wtq"];

[ma addObject: @"wtp"];

[ma addObject: @"www"];

for (int i = 0; i<[ma count]; i++) {

NSLog(@"value %@",[ma objectAtIndex:i]);

}

[ma addObject:@"wwttqq"];

NSLog(@"value: %@",[ma objectAtIndex:3]);

[ma insertObject:@"insertwtq" atIndex:3];

NSLog(@"value: %@",[ma objectAtIndex:3]);

NSLog(@"value: %@",[ma objectAtIndex:4]);

[ma removeObjectAtIndex:4];

NSLog(@"the length of ma is %d",[ma count]);

[ma removeObjectIdenticalTo:@"wtq"];

NSLog(@"the length of ma is %d",[ma count]);

你可能感兴趣的:(Objective-C)