다음과 같은 UITabBarController 기반 앱이 있습니다.어떻게 성능을 향상시킬 수 있습니까?
1) 웹에서 데이터를 가져 와서이를 CD로 파싱합니다 (정상적으로 작동합니다).
가{있는 viewDidLoad> loadRecordsFromCD (performBlockAndWait)> populateLocationsToSort}가
- (void)populateLocationsToSort {
//1. Get UserLocation based on mapview
self.userLocation = [[CLLocation alloc] initWithLatitude:self.userLocation.coordinate.latitude longitude:self.userLocation.coordinate.longitude];
// Loop thru dictionary-->Create locations
// 2. Loop thru dictionary to get Custom Objects
for (Location * locationObject in self.farSiman) {
// 3. Unload objects values into locals
//PARSE ALL DATA
NSString *coordenadas = locationObject.coordenadas;
NSArray *coordinatesArray = [coordenadas componentsSeparatedByString:@","];
NSString * latitude = [coordinatesArray objectAtIndex:0];
NSString * longitude = [coordinatesArray objectAtIndex:1];
NSString * storeDescription = locationObject.nombrePublico;
NSString * address = locationObject.direccion;
NSString * ciudad = locationObject.ciudad;
NSString * horario = locationObject.horario;
NSString * hor_LV = locationObject.hor_LV;
NSString * hor_S = locationObject.hor_S;
NSString * hor_D = locationObject.hor_D;
NSString * telefono = locationObject.telefono;
NSString * celular_TA = locationObject.celular_TA;
NSString * celular_TB = locationObject.celular_TB;
NSString * hrs24 = locationObject.hrs24;
NSString * driveThru = locationObject.driveThru;
//NSString * estado = locationObject.estado;
NSString * estado;
// IF self.open24hrs SELECTED
if (self.open24hrs) {
// Set it based on TimeComparator
if ([TimeComparator dealWithTimeStrings2:locationObject.hor_LV]) {
estado = @"Abierta";
} else {
estado = @"Cerrada";
}
} else {
estado = locationObject.estado;
}
// 4. Create MyLocation object based on locals gotten from Custom Object
CLLocationCoordinate2D coordinate;
coordinate.latitude = latitude.doubleValue;
coordinate.longitude = longitude.doubleValue;
MyLocation *annotation = [[MyLocation alloc] initWithName:storeDescription address:address coordinate:coordinate distance:0 ciudad:ciudad horario:horario telefono:telefono hrs24:hrs24 driveThru:driveThru hor_LV:hor_LV hor_D:hor_D hor_S:hor_S celular_TA:celular_TA celular_TB:celular_TB estado:estado];
// 5. Calculate distance between locations & uL
CLLocation *pinLocation = [[CLLocation alloc] initWithLatitude:annotation.coordinate.latitude longitude:annotation.coordinate.longitude];
CLLocationDistance calculatedDistance = [pinLocation distanceFromLocation:self.userLocation];
annotation.distance = calculatedDistance/1000;
//Add annotation to local NSMArray
[self.annotationsToSort addObject:annotation];
} //ENDS FOR LOOP
//SORT the created annotationsToSort
[self sort];
}
그것은 어레이를 취 [탭 2 년] 선택이어서 두 번째 탭 2) 표 1에서, 이는이 방법을 실행 CD에서 채워지고 객체를 만듭니다. hor_LV 필드를 취하여 날짜로 구문 분석하고 지금 비교하여 위치를 확인해야하기 때문에 새로운 객체를 만듭니다.
현재 84 개의 레코드가 가져오고 있고 두 번째 Tab (이 tableviewcontroller)을 탭하는 순간부터 이미 지연이 있음을 알 수 있으며 화면에 실제로 표시되는 시간입니다.
사용자가 데이터베이스에서 데이터를 가져 오기 전에 Tab 2에 전달 된 일부 필터를 Tab 2에 설정했기 때문에이 배열을 미리 구문 분석 할 수 없습니다. 그래서 나는 그 가져 오기가 탭 2로드로 발생해야합니다 알아요. 내 질문은,이 속도를 높이거나 지연을 그렇게 명백하게하지 않으려면 어떻게해야합니까?
ViewDidAppear 메서드에서 코드를 실행하고 작동하는 동안 활동 표시기를 표시 할 수 있습니까? 그러면 최소한 사용자는 탭 변경 사항을보고 프로그램이 데이터 페치 중임을 알 수 있습니다. – Scampbell