2012-10-26 3 views
1

응용 프로그램에 약간의 문제가 있습니다.
Views를 전환하면이 앱이 2 명의 정렬 algorythmen을 실행 한 후 약 3 ~ 10 초 정도 지연됩니다. (빠른 및 Bubblesort) 추가 스레드에서. 나는 문제가 어디에 있는지 모른다.UIViewController 전환시 문제가 발생했습니다.

여기에 코드 :

[alert show]; 
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), ^(void) { 
    time = [Sort sortRuns:(int)slider_durchlaeufe.value WithCapacity:(int)slider_ArraySize.value Reference:alert]; //time is a global reference to my Time object 
    [self setDataForStatistik]; // a Method to set the statisik for the next view 
    [alert dismissWithClickedButtonIndex:0 animated:true]; 
    }); 

나는 실패가이 코드에 생각합니다.

도와 주시면 감사하겠습니다.

Robybyte

답변

0

당신은 UI 업데이트 (또는 UI 업데이트를 트리거 할 수있는 변경) 주요 대기열을 확인해야합니다. 코드 샘플을 볼 때이 중첩 된 백그라운드 대기열과 비동기 적이며 주 대기열과 비동기식으로 서로 보입니다.

[alert show]; 
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, (unsigned long)NULL), ^(void) { 
    time = [Sort sortRuns:(int)slider_durchlaeufe.value WithCapacity:(int)slider_ArraySize.value Reference:alert]; //time is a global reference to my Time object 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     [self setDataForStatistik]; // a Method to set the statisik for the next view 
     [alert dismissWithClickedButtonIndex:0 animated:true]; 
    }); 
}); 

희망이 있습니다.

+0

예 매우 유용합니다. 고맙습니다 – Robybyte

관련 문제