int main (int argc, const char * argv[]) {
@autoreleasepool {
/* 1th Please store the following data in a dictionary and output the dictionary content as a string output: "xxx, age xxx, subject xxx, score xxx" (replace XXX with the corresponding data).
*/
NSString *name = @ "Zhang San";
Nsinteger age = 22;
NSNumber *[email protected];
NSString *subject = @ "Mathematics";
NSLog (@ "The first question");
NSString *name = @ "Zhang San";
Nsinteger age = 22;
NSNumber *[email protected];
NSString *subject = @ "Mathematics";
Nsdictionary *[email protected]{@ "name": Name,
@ ' age ': @ (age),
@ "Score": Score,
@ "subject": Subject};
NSString *str=[nsstring stringwithformat:@ "%@, age%@ years, subjects%@, score%@", dic[@ "name"],dic[@ "ages"],dic[@ "subject"],dic[@ " Score "];
NSLog (@ "%@", str);
}
NSNumber *[email protected];
NSNumber *[email protected];
NSNumber *[email protected];
NSNumber *[email protected];
NSNumber *[email protected];
Nsarray *brr=[nsarray arraywithobjects:a,b,c,d,e, nil];
NSLog (@ "second question");
2nd question: 12,9,34,56,11 deposit Nsarray Array, output: 1) Reverse output 2) descending output
NSLog (@ "Reverse output method one");
Nsarray *[email protected][@12,@9,@34,@56,@11];
For (Nsinteger i=[arr1 count]-1;i>=0;i--) {
NSLog (@ "%@", Arr1[i]);
}
NSLog (@ "Reverse output Method II");
nsarray* REVERSEDARRAY=[[BRR reverseobjectenumerator]allobjects];
For (ID str2 in Reversedarray)
{
NSLog (@ "%@", str2);
}
NSLog (@ "descending sort");
Nscomparator comp=^ (ID obj1,id obj2) {
Nscomparisonresult Result=[obj2 Compare:obj1];
return result;
};
Nsarray *sortedarr=[arr1 Sortedarrayusingcomparator:comp];
For (ID i in Sortedarr) {
NSLog (@ "%@", I);
}
NSLog (@ "3rd" to determine whether the intermediate directory exists ");
/* Question 3rd to determine if the intermediate directory exists
such as passing strings @ "/home/qianfeng/oc.txt" and @ "Qianfeng"
return: YES
Incoming string @ "/usr/qianfeng/oc.txt and @" Fengqian "
return: NO
*/
NSString *[email protected] "/home/qianfeng/oc.txt";
Nsrange rang1=[str rangeofstring:@ "Qianfeng"];
if (rang1.location==nsnotfound) {
NSLog (@ "not found");
}
else{
NSLog (@ "found at Loacation:%ld", rang1.location);
}
Nsrange rang2=[str rangeofstring:@ "Fengqian"];
if (rang2.location==nsnotfound) {
NSLog (@ "not found");
}
else{
NSLog (@ "found at Loacation:%ld", rang2.location);
}
NSLog (@ "4th" array of elements in Chinese sort);
/* The elements in the array 4th sorted by Chinese
*/
Nsarray *[email protected][@ "Light Rain", @ "Ann", @ "small wind", @ "Rongrong", @ "Zhang Tao" @ "Li Wenrong"];
Nsarray *sortedarr2=[arr sortedarrayusingselector: @selector (localizedcompare:)];
For (NSString *str in sortedArr2) {
NSLog (@ "%@", str);
}
return 0;
}
About the flashback, descending order of the array, whether the directory contains files, Chinese sort, etc.