私は NSURLConnection を使用する接続を持っています。この接続の進行状況を描画したいのですが、現在受信したデータと合計データ長を出力しようとすると、何か問題が発生しました。どうすれば修正できますか
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
receivedDataBytes += [data length];
NSLog(@"data: %f",receivedDataBytes);
[responseData appendData:data];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
self.HTTPStatusCode = [(NSHTTPURLResponse *)response statusCode];
totalFileSize = response.expectedContentLength;
NSLog(@"total: %lf",totalFileSize);
}
出力:
total: -1.000000
data: 1256.000000
total: -1.000000
data: 1034.000000
total: -1.000000
data: 1127.000000