NSURLConnection
대리인의 경우 총 콘텐츠 길이를 확인하려면 다음과 같이 구현하십시오. 서버는이 기능을 지원해야하지만, 대부분 정적 컨텐츠와 함께 잘 작동합니다 :
- (void)connection: (NSURLConnection*) connection didReceiveResponse: (NSHTTPURLResponse*) response
{
statusCode_ = [response statusCode];
if (statusCode_ == 200) {
download_.size = [response expectedContentLength];
}
}
그리고 다음과 같이 진행 업데이트 : 내 경우
- (void) connection: (NSURLConnection*) connection didReceiveData: (NSData*) data
{
[data_ appendData: data];
download_.progress = ((float) [data_ length]/(float) download_.size);
// Broadcast a notification with the progress change, or call a delegate
}
내가
size
이있는 다운로드 인스턴스가를 및
progress
속성. 그들은 관심있는 당사자에게 다운로드 진행 상태 또는 상태 변경을 알리는 글로벌
DownloadManager
개체가 소유합니다.