NSArray *arr = [[NSArray alloc]init];
NSArray *arr = [NSArray array];
NSArray *arr = @[@"1",@"2",@"3",@"4",@"5"];
NSLog(@"%ld",arr.count);
NSLog(@"%@",[arr objectAtIndex:1]);
NSLog(@"%@",arr[1]);
for (NSInteger i = 0 ; i < arr.count ; i ++){
NSLog(@"%@",arr[i]);
}
NSLog(@"%@",[arr containsObject:@"6"]);
Student *stu1 = [[Student alloc]initWithName:@"刘鑫奇"];
Student *stu2 = [[Student alloc]initWithName:@"高薪茹"];
Student *stu3 = [[Student alloc]initWithName:@"高小妖精"];
Student *stu4 = [[Student alloc]initWithName:@"高大贱人"];
NSArray *arr = [[NSArray alloc]initWithObjects:stu1,stu2,stu3,stu4, nil];
NSArray *arr = [NSArray arrayWithObjects:stu1,stu2,stu3,stu4,nil];
for (NSString *str in arr) {
NSLog(@"%@",str);
}
NSArray *arr1 = @[@"刘鑫奇",@"刘山山",@"刘星宇",@"刘能"];
NSArray *arr2 = @[@"腾飞",@"周胜民",@"商帅",@"郭洪瑞"];
NSArray *arr = @[arr1 , arr2];
for (NSArray *temp in arr){
for (NSString *str in temp){
NSLog( @"%@",str);
}
}
Student *stu1 = [[Student alloc]initWithName:@"刘鑫奇"];
Student *stu2 = [[Student alloc]initWithName:@"高薪茹"];
Student *stu3 = [[Student alloc]initWithName:@"高小妖精"];
Student *stu4 = [[Student alloc]initWithName:@"高大贱人"];
NSArray *arr1 = @[stu1,stu2,stu3];
NSArray *arr2 = @[stu4];
NSArray *arr = @[arr1 , arr2];
for (Student *temp in arr) {
for (Student *stu in temp) {
NSLog(@"%@",stu.name);
}
}
NSMutableArray *arr = [[NSMutableArray alloc]init];
NSMutableArray *arr1 = [[NSMutableArray alloc]initWithObjects:@"1",@"2",@"3",@"4", nil];
[arr addObject:@"8"];
NSLog(@"%@",arr);
[arr removeObjectAtIndex:2];
NSLog(@"%@",arr);
[arr replaceObjectsAtIndexes:1 withObject:@"7"];
NSLog(@"%@",arr);
[arr exchangeObjectAtIndex:1 withObjectAtIndex:4];
NSLog(@"替换%@",arr);
[arr removeAllObjects];
NSLog(@"清空%@",arr);
Book *book1 = [Book bookWithbookName:@"西游记" bookPrice:30];
Book *book2 = [Book bookWithbookName:@"水浒传" bookPrice:25];
Book *book3 = [Book bookWithbookName:@"三国演义" bookPrice:35];
Book *book4 = [Book bookWithbookName:@"金瓶梅(插图版)" bookPrice:40];
NSMutableArray *bookArr = [NSMutableArray arrayWithObjects:book1,book2,book3,book4, nil];
Book *book5 = [Book bookWithbookName:@"红楼梦" bookPrice:38];
[bookArr addObject:book5];
for (Book *book in bookArr) {
NSLog(@"%@ , %ld",book.bookName,book.bookPrice);
}
[bookArr removeObject:book5];
for (Book *book0 in bookArr) {
NSLog(@"%@ ,%ld ",book0.bookName , book0.bookPrice);
}
for (Book *temp in bookArr) {
if ([temp.bookName isEqualToString:@"红楼梦"]) {
temp.bookPrice = 150;
}
}
for (Book *temp in bookArr) {
NSLog(@"%@,%ld",temp.bookName,temp.bookPrice);
}