나는 5000 개의 지구와 도시가있다. 5000 군데를 coredata에 넣으려고합니다. 각 지구에는 도시가 있으며 각 도시에는 많은 지구가있을 수 있습니다. 나는 2 개의 실체, 즉 지구와 도시 쌍을 가지고있다. 어떻게 그렇게 효율적으로 할 수 있습니까?개체를 만들고 coredata를 올바르게 사용하는 방법?
for (int i=0; i<[IndonesiaDistrictToSave count]; i++) {
int index;
for (int j=0; j<[[IndonesiaDistrictToSave objectAtIndex:i] length]; j++) {
if([[IndonesiaDistrictToSave objectAtIndex:i] characterAtIndex:j]==','){
index=j;
}
}
NSString * DistrictName=[[IndonesiaDistrictToSave objectAtIndex:i] substringToIndex:index];
NSString * CityName=[[IndonesiaDistrictToSave objectAtIndex:i] substringFromIndex:index+1];
District * theDistrict = (District *)[GrabClass getObjectWithStringOfValue:DistrictName fromTable:@"District" withAttribut:@"Name"];
theDistrict.City= (City *)[GrabClass getObjectWithStringOfValue:CityName fromTable:@"City" withAttribut:@"Name"];
}
getObjectWithStringOfValue 개체가 이미 그것을 반환 존재하는 경우 조회하는 방법이지만, 오브젝트가 존재하지 않을 경우, 그것은 그때 새로운 하나를 만들 수 있으며, 그것을
를 반환 할 것 이 코드를 사용하여 모든 인도네시아 지역을 저장하면 4500 개 이상의 구역이 있습니다. 시간 간격을 사용하면 각 구역마다 0.013773이되지만 느려지므로 어떻게 빨리 처리 할 수 있습니까?
검색 결과의 mutablearray 프록시를 가져 오는 방법이 있습니까?
'-get *'으로 시작하는 함수의 특별한 사용법이 있습니다. 다른 접두사를 사용하는 것이 좋습니다. –
Alexsander가 맞습니다. 우리는 ManagedObject 서브 클래스에 -get * 및 -add * 접두사가 붙은 메소드를 사용했을 때 큰 어려움에 처했습니다. – vikingosegundo