如何在阵列中存储CGPoint

Nik*_*k's 6 iphone xcode cocoa-touch objective-c

嗨,我试图存储移动点,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]];
}
Run Code Online (Sandbox Code Playgroud)

但这不起作用我如何存储这些点 NSMutableArray

jus*_*mer 17

你应该在最后一行使用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]];
}
Run Code Online (Sandbox Code Playgroud)