NSValue (将结构体包装成NSValue)

将结构体包装成 NSValue ,并取出结构体

1     NSRect rect = {0, 0, 200,200};
2     NSValue *rectValue = [NSValue valueWithBytes:&rect objCType:@encode(NSRect)];
3     NSRect newRect;
4     [rectValue getValue:&newRect];
5     NSLog(@"%f,%f,%f,%f",newRect.origin.x,newRect.origin.y,newRect.size.width,newRect.size.height);

 

posted @ 2014-05-18 10:43  easydaylife  阅读(187)  评论(0编辑  收藏  举报