NSNumber, NSValue的使用

NSNumber

NSNumber *n = [NSNumber numberWithDouble:10.5];
int d = [n doubleValue];

int a = 20;
NSString *str = [NSString stringWithFormate:@"%d", a];
//string转int
[@"20" intValue];

//转化成NSNumber
@10
@YES
@'A'
@"A"

int value = 100;
@(value)

  

NSValue

//结构体转为Value对象
CGPoint p = CGPointMake(10, 10);
NSValue *value = [NSValue valueWithPoint:p];

//value转为对应的结构体
[value pointValue];
NSArray *array = @[value];

  

posted @ 2015-08-15 18:47  JonyFang  阅读(208)  评论(0编辑  收藏  举报