以下は、plistファイルから読み取ったバックグラウンドスレッドでビデオをアップロードするための私の方法です。
今私が必要としているのは、彼らがplistからすべてのエントリを読み取り、最初のブロックの実行を完了したら、新しいエントリがplistファイルに入っているかどうかを完了ブロックでチェックしたい..そしてstartThreadForUpload
、数時間後に呼び出すだけではない場合.どうすればそれを行うことができますか?今、完了ブロックで同じメソッドを呼び出すだけなので、実行を続けます...
-(void)startThreadForUpload{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
assetManager =[AssetManager sharedInstance];
NSDictionary *videoListDict= [assetManager getAllVideoFromPlist];
NSArray *videoListKeyArray=[videoListDict allKeys];
if(videoListKeyArray.count!=0)
{
for(NSString *key in videoListKeyArray){
NSData *videoData = [videoListDict objectForKey:key];
Video *vidObject = (Video *)[NSKeyedUnarchiver unarchiveObjectWithData:videoData];
amazonManger=[AmazonManager sharedInstance];
[amazonManger uploadVideoWithVideoName:vidObject.videoName IsImage:NO VideoObject:vidObject];
[amazonManger uploadVideoWithVideoName:vidObject.thumbImageName IsImage:YES VideoObject:vidObject];
}
}
dispatch_async(dispatch_get_main_queue(), ^(void) {
//Stop your activity indicator or anything else with the GUI
//Code here is run on the main thread
[self startThreadForUpload];
// WARNING! - Don't update user interfaces from a background thread.
});
});
}