正しく動作させるためにサウンド ファイルをダウンロードする必要があるアプリがあります。
サイズが 20Mb を超えるファイルをNSURLConnection
非同期でダウンロードしています。ダウンロードの割合を追跡するために を配置し、Apple が提案するprogressBarView
デリゲート メソッドを使用しています。NSUrlConnection
NSURLRequest *theRequest=[NSURLRequest requestWithURL:soundFileURL cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:20.0];
// create the connection with the request
// and start loading the data
NSURLConnection *theConnection;
theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
//[theConnection cancel];
//[theConnection start];
if (theConnection) {
// Create the NSMutableData that will hold
// the received data
// receivedData is declared as a method instance elsewhere
receivedData=[[NSMutableData data] retain];
} else {
// inform the user that the download could not be made
}
およびデリゲート メソッド
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data{
[receivedData appendData:data];
}
など ...
ダウンロードを開始すると、インターフェースが時々ハングアップし、progressView
ハングアップします。
1 つの注目すべき点と、おそらく別の質問: ユーザー インターフェイスを無効にしたため、ユーザーはダウンロードが完了するまで待たなければなりません。もちろん、そのことを伝えるメッセージを彼に渡します。Apple はそのために私のアプリを拒否しますか? 私はそれについてひどく心配しています
私の質問を読んでくれてありがとう:)