에 연결 나를 연결하는 동안 동결없이 작업 GUI를 유지하기 위해 새 스레드에서 연결을하려면내 이전 게시물의 사람 중 하나에서 배경
NSURLConnection *conn = [NSURLConnection connectionWithRequest:theRequest delegate:self];
를 사용하는 것이 좋습니다. 하지만 이제는 이것이 작동하지 않는다는 것을 알 수 있습니다.
이것은 전체적인 방법입니다.
- (void)postRequestWithURLState:(NSString *)url
{
NSString *bodyRequest = nil;
NSURL *requestURL = [NSURL URLWithString:url];
NSMutableURLRequest *theRequest = [[NSMutableURLRequest alloc] init];
//NSLog(@"-------------- bodyRequest: %@", bodyRequest);
[theRequest setURL:requestURL];
[theRequest setTimeoutInterval:2.0];
[theRequest setHTTPMethod:@"POST"];
[theRequest setHTTPBody:[bodyRequest dataUsingEncoding:NSASCIIStringEncoding]];
[self.oauthAuthentication authorizeRequest:theRequest];
NSURLConnection *conn = [NSURLConnection connectionWithRequest:theRequest delegate:self];
self.web = conn;
}
이는 greader라는 클래스의 일부입니다. 그래서이 모드에서이 방법을 사용합니다.
reader = [[greader alloc] init];
[reader setDelegate:self];
나는 [reader postRequestWithURLState : url]이라고합니다. 하지만이 방법으로 몇 초 동안 내 앱이 계속 정지됩니다. 몇 초 동안 앱을 정지하지 않고이 작업을 어떻게 수행 할 수 있습니까?
NSURLConnection
당신이 위임 방법 중 하나에 소요되는 뭔가 시간을하고 있습니까 실행NSThread
를 사용해보십시오? –