IOS Fourth Exam Questions

Source: Internet
Author: User
Tags ming sorts

1. For the string "2015-09-01 08:19:10" operation, output "08:19:10". Two methods of interception are required.

2. Access the following data in the array:

@[@{@ "name": @ "Chenfong" @ "Age": @ "32"},

@{@ "name": @ "Sun Ming" @ "age": @ "24"},

@{@ "name": @ "Wang Ming" @ "age": @ "12"},

@{@ "name": @ "Lisiek" @ "Age": @ "50"}

]

1) Sort by age (descending), output data

2) Delete "Chenfong" and output data

NSString *str=@"2015-09-01 08:19:10"; Nsrange Range1=[str rangeofstring:@"08:19:10"]; NSString*substr=[str substringwithrange:range1]; NSLog (@"first question--(1)"); NSLog (@"%@", SUBSTR); NSString*substr1=[str substringFromIndex:range1.location]; NSLog (@"first question--(2)"); NSLog (@"%@", SUBSTR1); Nsarray*[email protected][@{@"name":@"Chenfong",@" Age":@" +"},                        @{@"name":@"Sun Ming",@" Age":@" -"},                        @{@"name":@"Wang Ming",@" Age":@" A"},                        @{@"name":@"Lisiek",@" Age":@" -"}                        ]; Nsdictionary*[email protected]{@"name":@"Chenfong",@" Age":@" +"}; Nsdictionary*[email protected]{@"name":@"Sun Ming",@" Age":@" -"}; Nsdictionary*[email protected]{@"name":@"Wang Ming",@" Age":@" A"}; Nsdictionary*[email protected]{@"name":@"Lisiek",@" Age":@" -"}; 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 (@"The second question--(1)"); NSLog (@"sort after-(ascending)");  for(Nsdictionary *dicincharr) {NSLog (@"%@ %@", dic[@"name"],dic[@" Age"]); } NSLog (@"sort after-(descending)"); Nssortdescriptor*sorts1=[[nssortdescriptor Alloc]initwithkey:@" Age"Ascending:no];        [Arr Sortusingdescriptors:[nsarray arraywithobjects:sorts1, Nil]];  for(Nsdictionary *dicincharr) {NSLog (@"%@ %@", dic[@"name"],dic[@" Age"]); } NSLog (@"The second question--(2)");  for(intI=0; I<[arr count];i++) {nsdictionary*dic=Arr[i]; if([dic[@"name"] IsEqual:@"Chenfong"]) {[Arr removeobject:dic]; }        }         for(Nsdictionary *dicincharr) {NSLog (@"%@ %@", dic[@"name"],dic[@" Age"]); }

IOS Fourth Exam Questions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.