我正在使用NSOperationQueue,我想添加新的NSOperations到NSOperationQueue.它是一个排队,生活在一个类的单身实例.如果我可以通过传递代理将所有内容移动到静态类中,这将使事情变得更加容易.
这是我现在的代码,因为它在一个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]; }
如果我可以添加委托作为参数,我可以将所有这些代码放入共享单例类中,并从我的应用程序的任何地方调用它.
我想我可以使用NSNotification – 或者我可以使用某种块?
解决方法
原文地址:https://www.jb51.cc/c/114198.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。