배열에 주석을 추가하여지도에 여러 핀을 배치하려고합니다. 나는 for 루프 안에 모든 것을 가지고있다. 처음으로 루프를 반복하면 개체를 배열에 잘 추가합니다. 다시 돌아 가면 ... 배열에 0 개의 객체가 있습니다. 아무도 그 이유를 말할 수 있습니까?NSMutableArray가 조만간 출시 될 것으로 보입니다.
편집 : ARC를 사용하고 있습니다.
-(void)plotMultipleLocs {
float latitude;
float longitude;
NSRange commaIndex;
NSString *coordGroups;
for (int i=0; i<=cgIdArray.count; i++) {
coordGroups = [cgInAreaArray objectAtIndex:i];
commaIndex = [coordGroups rangeOfString:@","];
latitude = [[coordGroups substringToIndex:commaIndex.location] floatValue];
longitude = [[coordGroups substringFromIndex:commaIndex.location + 1] floatValue];
CLLocationCoordinate2D loc = CLLocationCoordinate2DMake(latitude, longitude);
MKCoordinateRegion reg = MKCoordinateRegionMakeWithDistance(loc, 1000, 1000);
self->mapView.region = reg;
MKPointAnnotation* ann = [[MKPointAnnotation alloc] init];
ann.coordinate = loc;
ann.title = [cgNameArray objectAtIndex:i];
ann.subtitle = [cgLocArray objectAtIndex:i];
NSMutableArray *mutAnnArray = [NSMutableArray arrayWithArray:annArray];
[mutAnnArray addObject:ann];
}
}
예 ... 동료가 페이지를 새로 고침하기 전에 그것을 알아 냈습니다. 하하. 답변을 주셔서 감사합니다. 나는 당신을 위해 그것을 표시 할 것이다. 그래서 당신은 대표를 얻는다. – tallybear
annArray에서 NSMutableArray로 annArray를 선언하고 작동하지 않는다고 생각하기 때문에 annArray에서 다른 배열을 만듭니다. 배열에 객체가 0 개 있습니다. annArray는 ivar입니다. – tallybear