我需要操作的指标加入NSOperationQueue,并希望它的工作原理是这样的:如何在向NSOperationQueue添加内容时获取索引?
@interface MyOperation : NSObject {
NSInteger index;
/* Do Something */
}
下面将myOperation的指数成员设置为它operationQueue的位置。
[operationQueue addOperation:myOperation]
编辑: 其实我使用的NSMutableDictionary来操作的指标作为存储对象和操作的名称为keys.Like这样的:
NSNumber* indexOfOperationInQueue;
NSMutableDictionary *dictionary;
...
-(void) AddOperation {
indexOfOperationInQueue = [NSNumber numberWithInt:value + 1];
[dictionary setObject:indexOfOperationInQueue forKey:@"operation0"];
}
操作被取消,crosspond键和对象中删除。