我有一个应用程序,我使用函数FSMoveObjectToTrashSync。它在后台线程中工作。我需要我的应用程序的能力,点击按钮暂停或继续(如果它暂停)我怎么能做到这一点?代码 例子:如何暂停/继续NSThread
NSMutableArray *fileArray = [NSMutableArray array withobjects:@"file1url", @"file2", @"file3", nil];
NSMutableArray *threadArray = [[NSMutableArray alloc] init];
-(void)myFunc{
for (NSURL *url in fileArray){
NSThread *thread = [[NSThread alloc] initWithTarget:self selector:@selector(mySelectorWith:) object:url];
[thread start];
[threadArray addObject:thread];
}
}
-(void)mySelectorWith:(NSURL *) url{
FSRef source;
FSPathMakeRef((const UInt8 *)[[url path] fileSystemRepresentation], &source, NULL);
FSMoveObjectToTrashSync(&source, NULL, kFSFileOperationDefaultOptions);
}
PS:对不起我的英语,我来自白俄罗斯是... =(