- (void)loadPreviewPageWithMagazineID:(NSString *)magazineID userID:(NSString *)userID {
NSMutableArray *operationArray = [NSMutableArray array];
for (NSInteger i = 1; i <= _numTotalPages; ++i) {
//NSLog(@"currenpage = %d, index = %d",_selectedPage,pageIndex);
NSDictionary *arguments = [NSDictionary dictionaryWithObjectsAndKeys:magazineID,
@"itemID", userID, @"userID", [NSNumber numberWithInt:i],
@"pageNumber", nil];
AFOperation *imageOperation =
[[AFOperation alloc] initWithTarget:self
selector:@selector(savePageToDisk:)
object:arguments];
[imageOperation addObserver:self forKeyPath:@"isFinished" options:0 context:nil];
[imageOperation setUserInfo:arguments];
[operationArray addObject:imageOperation];
[imageOperation release];
}
[_imageQueue addOperations:operationArray waitUntilFinished:YES];
}
- (void)processingMagazine:(NSDictionary *)arguments {
// load pdf document from decrypted data
NSString *userID = [arguments objectForKey:@"userID"];
NSString *magazineID = [arguments objectForKey:@"itemID"];
[self loadPreviewPageWithMagazineID:magazineID userID:userID];
}
그래서 때마다 내가 호출 할 필요가 UI를 업데이트합니다. 그러나 원하는 것을 이루기 위해 AFOperation 메서드가 끝날 때 UI 업데이트 코드를 추가 할 수 있습니다. 작동 방법에 추가하면 일부 처리가 완료되면 UI가 자동으로 업데이트됩니다.
또한 일반적으로 UI 업데이트는 MainThread에서 발생합니다. performSelectorInMainThread를 호출해도 아무런 문제가 없습니다.
UI를 업데이트 할 때까지 기다리는 대기열을 말하고 싶습니까? – Vignesh
대기열과 UI가 동시에 실행될 수 있습니까? – Lunayo
예. 확실히 가능합니다. 그것은 일어날 수있다. – Vignesh