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