그래프 작성을위한 일련의 점을 채우려고합니다. I를 사용하여 개별 값에 액세스 할 수Json 응답에서 NSMutableArray를 채우십시오.
(
{
precipIntensity = 0;
precipProbability = 0;
time = 1398123660;
},
{
precipIntensity = 0;
precipProbability = 0;
time = 1398123720;
},
{
precipIntensity = 0;
precipProbability = 0;
time = 1398123780;
})
: i는 인덱스 같다
responseArray[i][@"precipProbability"]
여기서 반환되는 데이터의 일례이다.
이러한 점으로 배열을 채우기 위해 노력하고 있지만 작동하지 않을 수 있습니다. 누군가 도울 수 있습니까?
이 나는 시도했다 :
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)입니다.
후 당신은 문제가있는 코드. 문제를 지적하십시오. – rmaddy
ArrayOfValues를 초기화 했습니까? 또한 변수 이름에 camelCasing을 사용하십시오. 클래스와 구별하려면'arrayOfValues'이어야합니다. –
i> [responseArray count]가 분명히 잘못되었습니다. 그리고 나는 "if (responseArray == nil || responseArray.count == 0)"또는 "if (responseArray.count == 0)"를 작성하는 것이 좋습니다. 아니면 더 나은 그냥 "for (NSDictionary * dict in responseArray)"; responseArray == nil 또는 responseArray.count에 대한 검사가 필요하지 않습니다. – gnasher729