标签:
//集合中,不能存储基本数据类型,如果你想要把基本数据类型存储到数组,集合中,就必须把它转换成基本数据类型的包装类 @autoreleasepool { //int float double char int a = 10; // [NSString stringWithFormat:@"%d",a]; //1.使用NSNumber 包装 int数据类型 NSNumber * number1 = [NSNumber numberWithInt:a]; NSLog(@"%@",number1); //2.直接转换成字符串 NSString * strInt = [number1 stringValue]; NSLog(@"strInt %@",strInt); //3.float包装成NSNumber NSNumber * number2 = [NSNumber numberWithFloat:98.98]; NSLog(@"number2 %@",[number2 stringValue]); //4.包装类转换成基本数据类型 int b = [number1 intValue]; NSLog(@"%d",b); } return 0;
标签:
原文地址:http://www.cnblogs.com/cwhking/p/4190097.html