怎么用NSMutableArray存储CGPoint,CGSize,CGRect,CGAffineTransform,UIEdgeInsets,UIOffset

来源:互联网 发布:js 延时执行函数 编辑:程序博客网 时间:2024/04/27 13:43

因为CGPoint,CGSize,CGRect,CGAffineTransform,UIEdgeInsets,UIOffset等不是NSObject的子类,因此不能够直接添加到NSMutableArray中,所以要先将其转换成NSObject的子类。NSValue类可以解决这个问题:

CGPoint point = CGPointMake(2,2);NSValue *value = [NSValue valueWithCGPoint:point];NSMutableArray *compare;compare=[NSMutableArray new];[compare addObject:value]; 


0 0
原创粉丝点击