您好,我正在尝试将移动点存储在 NSMutableArray
中,所以我尝试过这样的操作
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *move = [[event allTouches] anyObject];
CGPoint MovePoint = [move locationInView:self.view];
if (MovePointsArray==NULL) {
MovePointsArray=[[NSMutableArray alloc]init];
}
[MovePointsArray arrayWithObjects:[NSValue valueWithCGPoint:MovePoint]];
}
但这不起作用我如何将这些点存储在 NSMutableArray
最佳答案
你应该在最后一行使用 addObject:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *move = [[event allTouches] anyObject];
CGPoint MovePoint = [move locationInView:self.view];
if (MovePointsArray==NULL) {
MovePointsArray=[[NSMutableArray alloc]init];
}
[MovePointsArray addObject:[NSValue valueWithCGPoint:MovePoint]];
}
关于iphone - 如何将 CGPoint 存储在数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7688433/