-
#import <Foundation/Foundation.h>
-
-
-
int main(int argc, const char * argv[])
-
{
-
-
@autoreleasepool {
-
-
-
NSArray *array1 = [NSArray arrayWithObject:@"obj"];
-
NSArray *array2 = [NSArray arrayWithObjects:@"obj1", @"obj2", @"obj3", nil];
-
NSArray *array3 = [NSArray arrayWithArray:array2];
-
NSLog(@"array1 :%@", array1);
-
NSLog(@"array2 :%@", array2);
-
NSLog(@"array3 :%@", array3);
-
-
-
NSArray *array4 = [[NSArray alloc] initWithObjects:@"AAA", @"bbb", nil];
-
NSLog(@"array4 :%@", array4);
-
-
-
NSLog(@"array3 count :%d", [array3 count]);
-
-
-
NSLog(@"obj at index :%@", [array2 objectAtIndex:2]);
-
-
-
NSArray *array5 = [array3 arrayByAddingObject:@"ccc"];
-
NSLog(@"array5 :%@", array5);
-
-
-
-
NSString *joinString1 = [array5 componentsJoinedByString:@"|"];
-
NSLog(@"joinString :%@",joinString1);
-
-
-
-
NSLog(@"isContains :%d", [array5 containsObject:@"obj2"]);
-
-
-
-
NSLog(@"indexOfObject :%d",[array5 indexOfObject:@"obj3"]);
-
-
-
NSLog(@"lastObejct :%@", [array5 lastObject]);
-
-
-
for (id element in array5) {
-
NSLog(@"element :%@", element);
-
}
-
-
-
-
-
-
NSMutableArray *mutableArray = [NSMutableArray arrayWithCapacity:3];
-
-
[mutableArray addObject:@"aaa"];
-
[mutableArray addObject:@"eee"];
-
[mutableArray addObject:@"000"];
-
NSLog(@"addObject :%@", mutableArray);
-
-
-
[mutableArray insertObject:@"ccc" atIndex:0];
-
NSLog(@"insertObject :%@", mutableArray);
-
-
-
[mutableArray removeObject:@"ccc"];
-
NSLog(@"removeObject :%@", mutableArray);
-
-
-
[mutableArray removeObjectAtIndex:0];
-
NSLog(@"removeObjectAtIndex :%@", mutableArray);
-
-
-
[mutableArray removeLastObject];
-
NSLog(@"removeLastObject :%@", mutableArray);
-
-
-
[mutableArray addObjectsFromArray:array5];
-
NSLog(@"addObjectsFromArray :%@", mutableArray);
-
-
-
-
[mutableArray removeObjectsInArray:array2];
-
NSLog(@"removeObjectsInArray :%@", mutableArray);
-
-
-
-
[mutableArray replaceObjectAtIndex:0 withObject:@"==="];
-
NSLog(@"replaceObjectAtIndex :%@", mutableArray);
-
-
-
-
-
-
[mutableArray removeAllObjects];
-
NSLog(@"removeAllObjects :%@", mutableArray);
-
}
-
return 0;
-
}
日志:
-
2013-03-10 01:52:47.710 FoundationDemo[6215:303] array1 :(
-
obj
-
)
-
2013-03-10 01:52:47.712 FoundationDemo[6215:303] array2 :(
-
obj1,
-
obj2,
-
obj3
-
)
-
2013-03-10 01:52:47.713 FoundationDemo[6215:303] array3 :(
-
obj1,
-
obj2,
-
obj3
-
)
-
2013-03-10 01:52:47.714 FoundationDemo[6215:303] array4 :(
-
AAA,
-
bbb
-
)
-
2013-03-10 01:52:47.714 FoundationDemo[6215:303] array3 count :3
-
2013-03-10 01:52:47.715 FoundationDemo[6215:303] obj at index :obj3
-
2013-03-10 01:52:47.715 FoundationDemo[6215:303] array5 :(
-
obj1,
-
obj2,
-
obj3,
-
ccc
-
)
-
joinString :obj1|obj2|obj3|ccc
-
isContains :1
-
indexOfObject :2
-
lastObejct :ccc
-
element :obj1
-
element :obj2
-
element :obj3
-
element :ccc
-
addObject :(
-
aaa,
-
eee,
-
000
-
)
-
insertObject :(
-
ccc,
-
aaa,
-
eee,
-
000
-
)
-
removeObject :(
-
aaa,
-
eee,
-
000
-
)
-
removeObjectAtIndex :(
-
eee,
-
000
-
)
-
removeLastObject :(
-
eee
-
)
-
addObjectsFromArray :(
-
eee,
-
obj1,
-
obj2,
-
obj3,
-
ccc
-
)
-
removeObjectsInArray :(
-
eee,
-
ccc
-
)
-
replaceObjectAtIndex :(
-
"===",
-
ccc
-
)
-
removeAllObjects :(
-
)
-
阅读(542) | 评论(0) | 转发(0) |