NSNumber判断数值对象类型
2015-07-04 18:56
330 查看
参考:NSNumber判断数值对象类型
今天对在解析Plist时候发现,在Plist里NSNumber里面写的是什么样的数据,你读出来时,依据数值接近的类型转换
NSCFNumber : (double)0.11
NSCFNumber : (long)1
NSCFNumber : (bool)1
当我想要判断读出来的NSNumber是bool的话,用如下方法判断数据类型
今天对在解析Plist时候发现,在Plist里NSNumber里面写的是什么样的数据,你读出来时,依据数值接近的类型转换
NSCFNumber : (double)0.11
NSCFNumber : (long)1
NSCFNumber : (bool)1
当我想要判断读出来的NSNumber是bool的话,用如下方法判断数据类型
if([value isKindOfClass:[NSNumber class]]) { if (strcmp([value objCType], @encode(float)) == 0) { [cell.detailTextLabel.text = [NSString stringWithFormat:@"%.3f", [value floatValue]]]; } else if (strcmp([value objCType], @encode(double)) == 0) { [self.subTitleString appendString:[NSString stringWithFormat:@"%.3f", [value floatValue]]]; } else if (strcmp([value objCType], @encode(int)) == 0) { [self.subTitleString appendString:[NSString stringWithFormat:@"%d", [value intValue]]]; } else [self.subTitleString appendString: [NSString stringWithFormat:@"%d", [value intValue]]]; }
相关文章推荐
- iPhone/iPad连接电脑(win8.1)没有反应也不充电
- 图像增强对比度的方法——直方图均衡化
- java学习10--循环结构while、do while
- 基于spring4 websocket的简易聊天室
- C++ map的简单应用
- 2015070410 - EffactiveJava笔记 - 第61条 抛出与抽象对应的异常(2)
- (6)比特平面分层(Bit Plane Slicing)
- 一个不错的spring 学习博客
- 基本Sql语句汇总
- lintcode:Coins in a Line
- css3动画特效:纯css3制作win8加载动画特效
- Filter及FilterChain的使用详解
- qt的moc,uic,rcc命令的使用
- ServletContextListener使用详解
- Android手势识别的发展
- appium简明教程(5)——appium client方法一览
- 关于在64位win7下运行Virtualbox安装系统时出错(提示VBoxDD.DLL错误)的解决方案。
- 常用正则表达式大全
- ar151-s 路由器的配置
- 【轻松学排序算法】眼睛直观感受几种常用排序算法(转)