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]);

posted on 2011-10-05 17:20  wtq  阅读(748)  评论(0编辑  收藏  举报