NSNumber(只能包装数字类型)
NSNumber *num1 = [NSNumber numberWithInt:10];
NSNumber *num2 = [NSNumber numberWithFloat:10.1];
NSNumber *num3 = [NSNumber numberWithBool:YES];
NSNumber *num4 = @10;
NSValue(可以包装结构体)
+ (NSValue *)valueWithCGPoint:(CGPoint)point;
+ (NSValue *)valueWithCGVector:(CGVector)vector;
+ (NSValue *)valueWithCGSize:(CGSize)size;
+ (NSValue *)valueWithCGRect:(CGRect)rect;
CGPoint point = CGPointMake(10,20);
NSValue *value = [NSValue valueWithCGPoint:point];
NSLog(@"%@",value);//NSPoint: {10, 20}
网友评论