gpt4 book ai didi

ios - 从 Json 响应填充 NSMutableArray

转载 作者:行者123 更新时间:2023-11-29 03:01:49 25 4
gpt4 key购买 nike

我正在尝试填充点数组以进行绘图。以下是返回数据的示例:

(
{
precipIntensity = 0;
precipProbability = 0;
time = 1398123660;
},
{
precipIntensity = 0;
precipProbability = 0;
time = 1398123720;
},
{
precipIntensity = 0;
precipProbability = 0;
time = 1398123780;
})

我可以使用以下方法访问各个值:

responseArray[i][@"precipProbability"]

其中 i 等于索引。

我试图用这些点填充一个数组,但我似乎无法让它工作。有人可以帮忙吗?

我试过:

 if (!responseArray || !responseArray.count){
} else {
for (int i=0; i > [responseArray count]; i++) {
ArrayOfValues[i] = responseArray[i][@"precipProbability"];
}

if (!responseArray || !responseArray.count){
} else {
for (int i=0; i > [responseArray count]; i++) {
[ArrayOfValues insertObject:responseArray[i][@"precipProbability"] atIndex:i];
}

并且 ArrayOfValues 始终为空 (null)。

最佳答案

您的 for 循环条件是倒退的。你想要:

if (!responseArray || !responseArray.count){
} else {
for (NSUInteger i = 0; i < [responseArray count]; i++) {
[ArrayOfValues addObject:responseArray[i][@"precipProbability"]];
}

还要注意 i 的正确数据类型。

关于ios - 从 Json 响应填充 NSMutableArray,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23207873/

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