我有这样的指示:
[self someMethod:CGPointMake(50, 50)];
[self someMethod:CGPointMake(270, 50)];
[self someMethod:CGPointMake(50, 360)];
[self someMethod:CGPointMake(270, 360)];
...
我想像这样使用 NSArray 重构代码:
NSArray items = [NSArray initWithObjects:
CGPointMake(50, 50),
CGPointMake(270, 50),
CGPointMake(50, 360),
CGPointMake(270, 360),
...
nil];
我不知道正确的语法,有人可以帮助我吗?我试过了,但 XCode 告诉我“选择器元素类型 CGPoint 不是有效对象”:
CGPoint point = [CGPoint alloc];
for (point in items) {
[self someMethod:point];
}