iOS 第四期考核題

來源:互聯網
上載者:User

標籤:

1.對字串“2015-09-01 08:19:10”操作,輸出"08:19:10"。要求使用兩種截取方式。

2.數組中存取以下資料:

  @[@{@"name":@"陳豐",@"age":@"32"},

    @{@"name":@"孫明",@"age":@"24"},

    @{@"name":@"王明",@"age":@"12"},

    @{@"name":@"李西",@"age":@"50"}

   ]

     1)按年齡進行排序(降序),輸出資料

     2)刪除“陳豐”並輸出資料

 NSString *str=@"2015-09-01 08:19:10";        NSRange range1=[str rangeOfString:@"08:19:10"];        NSString *subStr=[str substringWithRange:range1];        NSLog(@"第一題-------(1)");        NSLog(@"%@",subStr);        NSString *substr1=[str substringFromIndex:range1.location];        NSLog(@"第一題-------(2)");        NSLog(@"%@",substr1);                        NSArray *[email protected][@{@"name":@"陳豐",@"age":@"32"},                        @{@"name":@"孫明",@"age":@"24"},                        @{@"name":@"王明",@"age":@"12"},                        @{@"name":@"李西",@"age":@"50"}                        ];                        NSDictionary *[email protected]{@"name":@"陳豐",@"age":@"32"};        NSDictionary *[email protected]{@"name":@"孫明",@"age":@"24"};        NSDictionary *[email protected]{@"name":@"王明",@"age":@"12"};        NSDictionary *[email protected]{@"name":@"李西",@"age":@"50"};        NSMutableArray *arr=[[NSMutableArray alloc]initWithObjects:dic1,dic2,dic3,dic4,nil];        NSSortDescriptor *sorts=[[NSSortDescriptor alloc]initWithKey:@"age" ascending:YES];        [arr sortUsingDescriptors:[NSArray arrayWithObjects:sorts, nil]];        NSLog(@"第二題-------(1)");        NSLog(@"排序後-------(升序)");        for(NSDictionary *dic in arr){            NSLog(@"%@ %@",dic[@"name"],dic[@"age"]);        }        NSLog(@"排序後-------(降序)");        NSSortDescriptor *sorts1=[[NSSortDescriptor alloc]initWithKey:@"age" ascending:NO];        [arr sortUsingDescriptors:[NSArray arrayWithObjects:sorts1, nil]];        for(NSDictionary *dic in arr){            NSLog(@"%@ %@",dic[@"name"],dic[@"age"]);        }        NSLog(@"第二題-------(2)");        for(int i=0;i<[arr count];i++){            NSDictionary *dic=arr[i];            if([dic[@"name"] isEqual:@"陳豐"]){                [arr removeObject:dic];            }        }        for(NSDictionary *dic in arr){            NSLog(@"%@ %@",dic[@"name"],dic[@"age"]);        }

 

iOS 第四期考核題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.