Tôi đang làm việc với NSOperationQueue và tôi muốn thêm NSOperations mới vào NSOperationQueue. Đó là một hàng đợi sống trong một trường hợp đơn sơ của một lớp tôi có. Nó sẽ làm mọi thứ trở nên dễ dàng hơn nhiều nếu tôi có thể di chuyển mọi thứ vào lớp tĩnh bằng cách chuyển giao cho đại biểu.Tôi có thể chuyển ủy nhiệm làm tham số mục tiêu-c
Đây là mã của tôi bây giờ vì nó sống ở - đây là trong một cellForRowAtIndexPath
NSString *key = [NSString stringWithFormat:@"%@%@",cell.dataItem.ItemID, cell.dataItem.ManufacturerID];
if (![self.imgOperationInQueue valueForKey:key]) {
ImageOperation *imgOp = [[ImageOperation alloc] initWithItemID:cell.dataItem.ItemID withManufacturerID:cell.dataItem.ManufacturerID withReurnType:kThumbnail];
imgOp.identifier = [NSString stringWithFormat:@"%i", cell.tag];
imgOp.delegate = self;
[[SharedFunctions sharedInstance] addImageOperationToQueue:imgOp];
[imgOp release];
// store these in the dictionary so we don;t queue up requests more than once
[self.imgOperationInQueue setValue:cell.dataItem.ItemID forKey:key];
}
Nếu tôi có thể thêm các đại biểu như một tham số tôi có thể đặt tất cả các mã này vào lớp singleton chia sẻ và gọi nó là từ bất cứ đâu trong ứng dụng của tôi.
Tôi cho rằng tôi có thể sử dụng NSNotification - hoặc tôi có thể sử dụng một khối sắp xếp nào đó không?