There is an integer 123456789, how to put the number of each digit of this integer, starting from the last place in the array, and traversing
1Nsinteger num=123456789;2NSString *str=[[nsstring Alloc]initwithformat:@"%ld", num];3Nsmutablearray *arr=[Nsmutablearray array];4 for(Nsinteger i=str.length-1; i>=0; i--){5 //The string is truncated at the bottom, one at a time6NSString *str1=[str Substringwithrange:nsmakerange (i,1)];7 [arr addobject:str1];8 }9 //nsarray *sortarr=[arr sortedarrayusingselector: @selector (Class)];TenNSLog (@"first question-------------"); One for(IDStrincharr) { ANSLog (@"%@", str); -}
1 //How to invert the string @ "abc123.xyz789"2NSString *STR1 =@"Uoy Evol I";3Nsmutablestring *str2=[[nsmutablestring alloc]initwithcapacity:str1.length];4Nsuinteger len=[str1 length];5 for(Nsinteger i= (len-1) ; I >=0; i--) {6[STR2 AppendFormat:@"%c", [str1 characteratindex:i]];//Notice that the char is returned here7}
Convert May 05, 2013 to 2013-05-05
Convert May 05, 2013 to 2013-05-05
1Nsmutablestring *str3=[[nsmutablestring Alloc]initwithformat:@"May 05, 2013"];2NSLog (@"The third question-------------");3NSLog (@"Original date:%@", STR3);4Nsrange RANGE1=[STR3 rangeofstring:@"years"];5 6[Str3 Replacecharactersinrange:nsmakerange (range1.location-1, range1.length+2) Withstring:@"-"];7Nsrange RANGE2=[STR3 rangeofstring:@"Month"];8[Str3 Replacecharactersinrange:nsmakerange (range2.location-1, range2.length+2) Withstring:@"-"];9Nsrange RANGE3=[STR3 rangeofstring:@"Day"];Ten[Str3 Replacecharactersinrange:nsmakerange (Range3.location, range3.length) withstring:@""]; OneNSLog (@"Date converted:%@", STR3);
oc--has such an integer 123456789, how to put the number of each digit of this integer, starting from the last place in the array, and traversing the reverse output string