You need to do the following:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *move = [[event allTouches] anyObject]; CGPoint MovePoint = [move locationInView:self.view]; if (MovePointsArray == NULL) { MovePointsArray = [[NSMutableArray arrayWithObjects:[NSValue valueWithCGPoint:MovePoint, nil]; } else { [MovePointsArray addObject:[NSValue valueWithCGPoint:MovePoint]]; } }
do not forget to save / pass the array, as you do not see, to use the accessor property.
Best of all, you should allocate / initialize the array in your init method, and then only here:
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event { UITouch *move = [[event allTouches] anyObject]; CGPoint MovePoint = [move locationInView:self.view]; [MovePointsArray addObject:[NSValue valueWithCGPoint:MovePoint]]; }
source share