#import <Foundation/Foundation.h>
int main(int argc, const char * argv[]) {
@autoreleasepool {
//数组
//快速创建数组
NSArray *[email protected][@"MON",@"TUE",@"WED",@"THU",@"FRI",@"SAT",@"SUN" ];
NSLog(@"%@",week);
//创建一个空数组
NSArray *arr=[[NSArray alloc]init];
NSArray *arr1=[NSArray array];
//注意数组接使用nil(空) 进行结束 不可删除
//NSArray *arr2=[NSArray arrayWithObjects:@"das",@"dsa",nil];
//NSArray *arr3=[NSArray arrayWithObject:@"b"];
//复制
NSArray*new=[NSArray arrayWithArray:week];
NSLog(@"%@",new);
//获取数组中元素的个数
NSInteger count=[new count];
NSLog(@"个数:%ld",count);
//根据数下标访问数组内的元素
NSString *str=[new objectAtIndex:1];
NSLog(@"%@",str);
//向数组内添加一个元素
NSArray *add=[new arrayByAddingObject:@"sdfg"];
NSLog(@"%@",add);
//连接
NSString *new1=[new componentsJoinedByString:@","];
NSLog(@"%@",new1);
//判断数组内是否包含冒个对象
BOOL resu=[new containsObject:@"THU"];
NSLog(@"%d",resu);
//查询冒个对象在数组中的位置
NSInteger index=[new indexOfObject:@"THU"];
NSLog(@"%d",(int)index+1);
//获取数组最后一个元素
NSString *lastring=[new lastObject];
NSLog(@"%@",lastring);
}
return 0;
}