Pet*_*isu 2 multithreading nsoperation nsoperationqueue ios
有没有办法如何userInfo NSDictionary获得一个NSOperation?
基本上我想为NSOperation分配一个ID,以后我想检查一下,如果这个ID已经分配给了NSOperation
- (void)processSmthForID:(NSString *)someID {
for (NSOperation * operation in self.precessQueue.operations) {
if ([operation.userInfo[@"id"] isEqualToString:someID]) {
// already doing this for this ID, no need to create another operation
return;
}
}
NSOperation * newOperation = ...
newOperation.userInfo[@"id"] = someID;
// enqueue and execute
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
777 次 |
| 最近记录: |