对于iPad/iPhone应用程序,如何获得一系列积分?

Jer*_*y L 4 core-animation quartz-graphics ios

我们可以拥有一个NSMutableArray对象,并为其添加对象.

但是CGPoint不是对象...... Point对象是否适合添加到NSMutableArray对象?

我看到一些代码NSStringFromCGPoint用于创建一个NSString对象,以便它可以添加到数组中,然后CGPointFromString用于获取CGPoint后面...但是这看起来太多了一个黑客......

sch*_*sch 10

您可以使用NSValue包装器将点存储在数组中:

CGPoint a = CGPointMake(10.0, 10.0);
[array addObject:[NSValue valueWithCGPoint:a]];

CGPoint b = [(NSValue *)[array objectAtIndex:0] CGPointValue];
Run Code Online (Sandbox Code Playgroud)


Ham*_*son 6

您应该使用NSValue类和以下方法:

+ valueWithCGPoint:
- CGPointValue
Run Code Online (Sandbox Code Playgroud)