가변 배열에 객체를 추가하는 중 이상한 문제가있는 것 같습니다. 것은 내가 외부 데이터베이스에서 얻은 좌표와 사전의 배열을 가지고 있으며, 그들을 통해 루프를 할 좌표를 추출, 사용자 정의 주석 객체를 생성하고 다음 변경할 배열에 추가하려고합니다.Cocoa : 루프에서 가변 배열에 객체를 추가하는 중 오류가 발생했습니다.
문제는 그 쇼에서 그들을 얻을 배열은 단 1 개체가 첫 번째 배열 5.
을 가지고 도와주세요! 여기
코드 (비고 : testArray 내가 그것을 노호 작성하지 않습니다 내 클래스의 속성은, 난 그냥 개체를 저장하는 데 사용하려고입니다)입니다감사합니다!
int times; int count;
count=[theResults count];
// do the loop oh yeah do the loop
for (times=0;times<count; times=times+1)
{
// create dictionary with contents of array
NSDictionary * testDict = [theResults objectAtIndex:times];
NSLog(@"the results has %i objects", [theResults count]);
NSLog(@"object latitude is %@",[radarDict valueForKey:@"radarLatitude"]);
NSLog(@"object longitude is %@", [radarDict valueForKey:@"radarLongitude"]);
double testLatitude=[[radarDict valueForKey:@"radarLatitude"] doubleValue];
double testLongitude=[[radarDict valueForKey:@"radarLongitude"] doubleValue];
CLLocationCoordinate2D testCoordinate;
testCoordinate.longitude=testLongitude;
testCoordinate.latitude=testLatitude;
CustomAnnotations* tempAnnotation = [[CustomAnnotations alloc] initWithLocation:testCoordinate];
testArray = [[NSMutableArray alloc] initWithCapacity:count];
[testArray addObject:tempAnnotation];
[tempAnnotation release];
}
감사합니다. 방금 그걸 봤어. 그 명백한 예치 그러나 그것은 나를 위해 없었다 :) 감사 – Daniel
걱정 없음, 우리 모두는 그 종류의 재료를한다 :) – sosborn