gpt4 book ai didi

ios - NSMutable 数组未替换为新对象

转载 作者:行者123 更新时间:2023-11-28 22:30:40 24 4
gpt4 key购买 nike

我有一个 NSMutableArray 存储这样的 int 值

[self.destinationPostionPointer addObject:[NSNumber numberWithInt:0]];
[self.destinationPostionPointer addObject:[NSNumber numberWithInt:0]];

在一组代码之后,我试图用

替换上面的对象
[self.destinationPostionPointer replaceObjectAtIndex:0 withObject:[NSNumber numberWithInt:1]];

但是 destinationPositionPointer 数组没有替换具有整数值 1 的对象。

最佳答案

您没有为这个数组分配内存。所以你需要在你的代码中写下这一行

  - (void)viewDidLoad
{
self.destinationPositionPointer = [[NSMutableArray alloc] init];
}

关于ios - NSMutable 数组未替换为新对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17564153/

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