2011-08-10 3 views
0

웹 API에서 작은 비트의 데이터 (약 50 바이트)를 얻으려고 NSURLRequestNSURLConnection을 사용하려고합니다. 나는 아래의 코드가 옳다는 것을 확신하지만, 실제로 수신 된 데이터를 얻고 그 데이터가 모두 다운로드 될 때 어떻게 감지합니까?NSURLConnection이 완료되었을 때를 감지하는 방법

NSURLRequest *req = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.com"] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0]; 
NSURLConnection *con = [[NSURLConnection alloc] initWithRequest:req delegate:self]; 

답변

5

, 당신은 connection:didReceiveData: 방법으로 데이터를 얻을 수 있고, connectionDidFinishLoading: 메소드가 호출 될 때하여 수술은 끝났어. 한편, 조작 중에 에러가 발생하면 connection:didFailWithError:이 호출됩니다.

+0

문서 페이지 [여기] (http://developer.apple.com/library/mac/#documentation/Foundation/Reference/NSURLConnectionDelegate_Protocol/Reference/Reference.html) – bobobobo

관련 문제