我像NSMutableArray
那样存储了一堆CGPoint
s
safeZonePoints = [NSMutableArray array];
[safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(234, 160)]];
[safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(284, 210)]];
[safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(334, 160)]];
[safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(284, 10)]];
[safeZonePoints addObject:[NSValue valueWithCGPoint:CGPointMake(234, 160)]];
现在我可以从数组中获取NSValue
,但如何将NSValue
转换回CGPoint
?
答案 0 :(得分:3)
做这样的事情:
NSValue *cgpointObj = [NSValue valueWithCGPoint:CGPointMake(234, 160)];
CGPoint loc = cgpointObj.pointValue;
请查看以下链接:CGPoint to NSValue and reverse
回答你的问题应该足够了。