一个整数123456789,从末尾开始依次放入到数组中,遍历出来

#import <Foundation/Foundation.h>

#define NSLog(FORMAT, ...) printf("%s ", [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String])

int main(int argc, const char * argv[]) {

    @autoreleasepool {

        NSMutableString *mustr=[[NSMutableString alloc]init];

        

        int i=123456789;

        NSString *stringInt = [NSString stringWithFormat:@"%d",i];

        

        mustr=[NSMutableString stringWithString:stringInt];

        NSMutableArray *arr=[[NSMutableArray alloc]init];

        NSRange rang;

        

      

        for (int j=mustr.length-1; j+1 != nil; j--) {

            

            rang.location=j;

            

            rang.length=1;

            

            NSString *newStr3=[mustr substringWithRange:rang];

            

            //NSLog(@"%@",newStr3);

            

            [arr addObject:newStr3];

        }

        NSLog(@"输出结果为:");

    

        for(NSDictionary *dic in arr){

        

            NSLog(@"%@",dic);

        }

    

    }

    return 0;

}

原文地址:https://www.cnblogs.com/shaowenlong/p/5116641.html