【Foundation-86-3】#import <Foundation/NSValue.h> 初始化
来源:互联网 发布:在淘宝买衣服好吗 编辑:程序博客网 时间:2024/06/15 12:03
@interface NSNumber : NSValue
- (instancetype)initWithCoder:(NSCoder *)aDecoder NS_DESIGNATED_INITIALIZER;
//实例方法 初始化
- (NSNumber *)initWithChar:(char)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithUnsignedChar:(unsigned char)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithShort:(short)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithUnsignedShort:(unsigned short)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithInt:(int)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithUnsignedInt:(unsigned int)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithLong:(long)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithUnsignedLong:(unsigned long)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithLongLong:(long long)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithUnsignedLongLong:(unsigned long long)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithFloat:(float)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithDouble:(double)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithBool:(BOOL)value NS_DESIGNATED_INITIALIZER;
- (NSNumber *)initWithInteger:(NSInteger)value NS_AVAILABLE(10_5, 2_0) NS_DESIGNATED_INITIALIZER;
//64 推荐使用,其他少用
- (NSNumber *)initWithUnsignedInteger:(NSUInteger)value NS_AVAILABLE(10_5, 2_0) NS_DESIGNATED_INITIALIZER;
//获取数据
@property (readonly) char charValue;
@property (readonly) unsigned char unsignedCharValue;
@property (readonly) short shortValue;
@property (readonly) unsigned short unsignedShortValue;
@property (readonly) int intValue;
@property (readonly) unsigned int unsignedIntValue;
@property (readonly) long longValue;
@property (readonly) unsigned long unsignedLongValue;
@property (readonly) long long longLongValue;
@property (readonly) unsigned long long unsignedLongLongValue;
@property (readonly) float floatValue;
@property (readonly) double doubleValue;
@property (readonly) BOOL boolValue;
@property (readonly) NSInteger integerValue NS_AVAILABLE(10_5, 2_0);//64 推荐使用,其他少用
@property (readonly) NSUInteger unsignedIntegerValue NS_AVAILABLE(10_5, 2_0);
@property (readonly, copy) NSString *stringValue;//nsnumber 变成字符串
NSNumber *strNumber = [NSNumber numberWithInteger:3]; NSString *str = [strNumber stringValue]; NSLog(@"%@",str);
- (NSComparisonResult)compare:(NSNumber *)otherNumber;//比较,排序用
NSNumber *number1 = [NSNumber numberWithInteger:13]; NSNumber *number2 = [NSNumber numberWithInteger:14]; NSComparisonResult result = [number1 compare:number2]; if (result == NSOrderedAscending) { NSLog(@"升序");//number2 比 number1 大 }else if (result == NSOrderedSame){ NSLog(@"一致"); }else if (result == NSOrderedDescending){ NSLog(@"降序"); }else{ NSLog(@"error"); }
- (BOOL)isEqualToNumber:(NSNumber *)number;//判断是否一致
NSNumber *number1 = [NSNumber numberWithInteger:13]; NSNumber *number2 = [NSNumber numberWithInteger:14]; if ([number1 isEqualToNumber:number2]) { NSLog(@"same"); }else{ NSLog(@"nonono"); }
- (NSString *)descriptionWithLocale:(id)locale;//本地化的字符串,规范化。继续研究 NSLocale
NSNumber *number2 = [NSNumber numberWithInteger:1314]; NSString *string = [number2 descriptionWithLocale:[NSLocale currentLocale]]; NSLog(@"%@",string);
@end
@interface NSNumber (NSNumberCreation)
//类方法初始化
+ (NSNumber *)numberWithChar:(char)value;
+ (NSNumber *)numberWithUnsignedChar:(unsigned char)value;
+ (NSNumber *)numberWithShort:(short)value;
+ (NSNumber *)numberWithUnsignedShort:(unsigned short)value;
+ (NSNumber *)numberWithInt:(int)value;
+ (NSNumber *)numberWithUnsignedInt:(unsigned int)value;
+ (NSNumber *)numberWithLong:(long)value;
+ (NSNumber *)numberWithUnsignedLong:(unsigned long)value;
+ (NSNumber *)numberWithLongLong:(long long)value;
+ (NSNumber *)numberWithUnsignedLongLong:(unsigned long long)value;
+ (NSNumber *)numberWithFloat:(float)value;
+ (NSNumber *)numberWithDouble:(double)value;
+ (NSNumber *)numberWithBool:(BOOL)value;
+ (NSNumber *)numberWithInteger:(NSInteger)value NS_AVAILABLE(10_5, 2_0);
+ (NSNumber *)numberWithUnsignedInteger:(NSUInteger)value NS_AVAILABLE(10_5, 2_0);
@end
- 【Foundation-86-3】#import <Foundation/NSValue.h> 初始化
- 【Foundation-86-2】#import <Foundation/NSValue.h>
- 【Foundation-86-1】#import <Foundation/NSValue.h>基础创建
- 【Foundation-26-4】#import <Foundation/NSDictionary.h>可变字典初始化
- 【Foundation-10-3】#import <Foundation/NSArray.h>遍历
- 【Foundation-10-3】#import <Foundation/NSArray.h>排序
- 【Foundation-26-3】#import <Foundation/NSDictionary.h>字典,操作
- 【Foundation-10-1】#import <Foundation/NSArray.h>
- 【Foundation-10-2】#import <Foundation/NSArray.h>
- Foundation--NSValue
- foundation-NSValue
- Foundation.h下的 NSValue/NSNumber
- 【Foundaton-10-3】#import <Foundation/NSArray.h>字符串操作
- 【Foundation-36-1】#import <Foundation/NSIndexPath.h>树结构
- 【Foundation-37-1】#import <Foundation/NSIndexSet.h>不可索引集合
- 【Foundation-37-2】#import <Foundation/NSIndexSet.h>可变索引集合
- 【Foundation-62-1】#import <Foundation/NSRange.h>范围
- 【Foundation-10-4】#import <Foundation/NSArray.h>可变数组,一般
- 浅谈UIScrollView的用法
- iOS大典之Core Data
- openlayers中设置地图缩放级别
- 《C语言程序设计(第二版新版)》课后练习
- group by 子句的细节
- 【Foundation-86-3】#import <Foundation/NSValue.h> 初始化
- eclipse的快捷键
- MyBatis入门09之整合spring
- 我的Android进阶之旅------>修改Android签名证书keystore的密码、别名alias以及别名密码
- 通过触发器解决统计,count(*)问题
- 98 git fetch/merge
- android时间日期选择器,监听
- TCP滑动窗口与拥塞窗口
- codevs2924数独挑战 深度优先搜索