2012-06-21 33 views

回答

3

你可以繼承NSOperation(如果你還沒有這樣做的話),一個URL屬性添加到您的子類,請與你將要添加URL的操作是否已經在隊列:

if (![[queue.operations valueForKey:@"URL"] containsObject:myURL]) { 
    //add operation... 
} else { 
    //operation with this URL is already in the queue... 
} 

如果您有批次正在進行操作,您可能需要單獨跟蹤NSMutableSet中的URL,這對於成員資格測試更有效。操作完成後,您必須從集中移除網址。

相關問題