내 AppDelegate에 다음 메소드가 있습니다. updateView에서 라벨을 업데이트하고 ASIHTTPRequest를 통해 업로드를 수행하는 방법을 찾을 수 없습니다. 아래 코드에서 업로드 (startUpload)는 수행하지만 레이블 (updateLabel)은 업데이트하지 않습니다. startUpload에 대한 호출을 주석 처리하면 레이블이 업데이트됩니다. 또한 uploadViewController 내에서 디스패치 큐를 만들려고했는데 비슷한 결과가 있었는데 두 메서드 중 하나만 작동 할 수있었습니다. UploadViewController에서dispatch_async를 사용할 때 문제가 발생합니다. 동일한 컨트롤러에서 두 가지 함수 호출을 실행할 수 없습니까?
- (void) showProgressView:(NSString *)filePath {
NSView *view = [uploadViewController view];
dispatch_queue_t queue = dispatch_get_global_queue(0,0);
dispatch_async(queue, ^{
// assigns the upload view to the root NSPanel
[box setContentView:view];
});
dispatch_async(queue, ^{
// starts the upload using ASIHTTPRequest
[uploadViewController startUpload:filePath];
});
dispatch_async(queue, ^{
// updates a label in the upload view
[uploadViewController updateLabel];
});
}
:
-(void)startUpload:(NSString *)filePath {
HandZipper *handZipper = [HandZipper alloc];
zipPath = [handZipper compressHands:(filePath):(processStatus)];
ASIFormDataRequest *request = [[[ASIFormDataRequest alloc] initWithURL:[NSURL URLWithString:@"http://allseeing-i.com/ignore"]] autorelease];
[request setRequestMethod:@"PUT"];
[request setPostBodyFilePath:zipPath];
[request setShouldStreamPostDataFromDisk:YES];
[request setDelegate:self];
[request setUploadProgressDelegate:progressIndicator];
[request setDidFinishSelector:@selector(postFinished:)];
[request setDidFailSelector:@selector(postFailed:)];
[request startSynchronous];
}
ty, ty. 잘 설명하고 효과가있었습니다. –