星空网 > 软件开发 > 操作系统

iOS NSNumber转化NSString之description

我们经常需要把一个数字转成字符串,当你不需要配合其他字符串的时候可以用description.

 1   /** 2    description属于NSObject 3    值是NSNumber时候,不用stringWithFormate来转化成字符串了.简便得多 4    在解析/赋值的时候比较有用,当我们需要NSString的时候,给我们的数据却是NSNumber.. 5   */ 6    7   //从字典取出的是NSNumber 8   NSDictionary * dict = @{ 9               @"一":@1,10               @"二":@2,11               @"三":@3};12   //取出的NSNumber 被转换成了 NSString13   NSString * str = [dict[@"二"] description];14   NSLog(@"str=%@",str);15   16   //从字典取出数据是NSString17   NSDictionary * dict2 = @{@"1":@"一",18               @"2":@"二",19               @"3":@"三"};20   //因为是字符串,这里description方法就没什么实际作用了21   NSString * str2 = [dict2[@"2"] description];22   NSLog(@"str2=%@",str2);

 




原标题:iOS NSNumber转化NSString之description

关键词:IOS

IOS
*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

​CPI​:https://www.goluckyvip.com/tag/15174.html
​eco rolen:https://www.goluckyvip.com/tag/15175.html
​GGives:https://www.goluckyvip.com/tag/15176.html
​GS SHOP:https://www.goluckyvip.com/tag/15177.html
​Luxottica:https://www.goluckyvip.com/tag/15178.html
​mmooham:https://www.goluckyvip.com/tag/15179.html
桂林酒店销售多少钱 桂林旅游宾馆价格:https://www.vstour.cn/a/410227.html
十里银滩旅游攻略玩什么住哪里怎么去?:https://www.vstour.cn/a/410228.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流