您的位置:首页 > 移动开发 > IOS开发

ios判断数(int float double bool)

2013-02-20 13:53 351 查看
+(NSString*)fromTypeToString:(id)data{
NSNumber *myNumber = (NSNumber *)data;
int minThreshold = [myNumber
intValue];
if ((int)minThreshold <
1 )
{
NSLog(@"Not a number");
}
else{
if (strcmp([myNumber
objCType], @encode(BOOL)) ==
0) {
returnString = @"BOOL";
NSLog(@"this is a bool");
} else if (strcmp([myNumber
objCType], @encode(int)) ==
0) {
returnString = @"int";
NSLog(@"this is an int");
}
else if (strcmp([myNumber
objCType], @encode(float)) ==
0) {
returnString = @"float";
NSLog(@"this is an float");
}
else if (strcmp([myNumber
objCType], @encode(double)) ==
0) {
returnString = @"double";
NSLog(@"this is an double");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: