首页 > 代码库 > NSNumber NScopy
NSNumber NScopy
NSNumber生成:NSNumber *number1 = [[NSNumber alloc] initWithInt:1000];转成NSNumber型:// short型→NSNumber型NSNumber *num = [NSNumber numberWithShort:32767];// int型→NSNumber型NSNumber *num = [NSNumber numberWithInt:2147483647];// long型→NSNumber型NSNumber *num = [NSNumber numberWithLong:2147483647];// float型→NSNumber型NSNumber *num = [NSNumber numberWithFloat:42.195f];// double型→NSNumber型NSNumber *num = [NSNumber numberWithDouble:3.1415f];// BOOL型→NSNumber型NSNumber *num = [NSNumber numberWithBool:YES];// char型→NSNumber型NSNumber *num = [NSNumber numberWithChar:a];NSNumber型转为NSString型:(同理,short/int/long/float/bool/char Value)NSString *str = [num stringValue];NSNumber型是否相同的比较:BOOL b = [num1 isEqualToNumber:num2];
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。