【发布时间】:2013-04-27 10:56:11
【问题描述】:
有没有办法让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
}
【问题讨论】:
标签: ios multithreading nsoperation nsoperationqueue