gpt4 book ai didi

iphone - 如何将 CGPoint 存储在数组中

转载 作者:太空狗 更新时间:2023-10-30 03:39:34 25 4
gpt4 key购买 nike

您好,我正在尝试将移动点存储在 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com