读书人

NSNumber判断数值对象部类

发布时间: 2012-09-24 13:49:41 作者: rapoo

NSNumber判断数值对象类型

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]]];                        }  
?

读书人网 >移动开发

热点推荐