码迷,mamicode.com
首页 > 其他好文 > 详细

数组的练习

时间:2014-07-18 09:35:41      阅读:160      评论:0      收藏:0      [点我收藏+]

标签:des   style   blog   color   for   re   

    //数组的方法调用与熟练
    NSArray *array=@[@11,@22,@33,@"ldq"];
    NSArray *array1 =[array arrayByAddingObject:@"dkf"];
    array1=[NSArray arrayWithObjects:@11,@222, nil];
    //NSLog(@"%@",array1);
    
    NSArray *array3=[NSArray arrayWithArray:array];
    //[array3 ];
    //NSLog(@"%@",array3);
    NSString *array11[]={@"123",@"344"};
    NSArray *array4=[[NSArray alloc]initWithObjects:array11 count:2];
    //NSLog(@"###%@",array4);
    [array4 writeToFile:@"/Users/apple/Desktop/test.plist" atomically:YES];
    NSArray *ary= [[NSArray alloc]initWithContentsOfFile:@"/Users/apple/Desktop/test.plist"];
    
    NSLog(@"$$%@",ary);
    NSInteger cout=[ary count];
    NSLog(@"@@@%d",cout);
    
    NSInteger a=[ary indexOfObject:@"344"];
    NSLog(@"%d",a);
    NSMutableArray *mArray = [NSMutableArray arrayWithCapacity:10];
    [mArray addObjectsFromArray:ary];
    [mArray replaceObjectAtIndex:1 withObject:@"www"];
    NSLog(@"%@",mArray);
    
    //排序数组,用自己写的方法comper:
    Student *stu1=[[Student alloc]init];
    stu1.age=56;
    Student *stu2=[[Student alloc]init];
    stu2.age=45;
    Student *stu3=[[Student alloc]init];
    stu3.age=78;
    NSArray *a1=[NSArray arrayWithObjects:stu1,stu2,stu3, nil];
    NSArray *a2=[a1 sortedArrayUsingSelector:@selector(comper:)];
    for (Student *st in a2) {
        NSLog(@"%d",st.age);

    }
    
    
    return YES;

数组的练习,布布扣,bubuko.com

数组的练习

标签:des   style   blog   color   for   re   

原文地址:http://www.cnblogs.com/lidongq/p/3851936.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!