【发布时间】:2014-06-06 06:05:37
【问题描述】:
以下是我在从 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.
});
});
}
【问题讨论】:
标签: ios objective-c grand-central-dispatch nstimer background-thread