以下是我在从 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.
});
});
}