Tag: nsoperationqueue

NSOperationqueue背景,下载图片

我创build了一个NSOperationQueue来下载图片(来自Twitter for Cell): NSOperationQueue *queue = [[NSOperationQueue alloc]init]; [queue addOperationWithBlock:^{ NSString *ImagesUrl = [[NSString alloc]initWithFormat:@"http://api.twitter.com/1/users/profile_image/%@",[[status objectForKey:@"user"]objectForKey:@"screen_name"]];; NSURL *imageurl = [NSURL URLWithString:ImagesUrl]; UIImage *img = [UIImage imageWithData:[NSData dataWithContentsOfURL:imageurl]]; [[NSOperationQueue mainQueue]addOperationWithBlock:^{ if (img.size.width == 0 || [ImagesUrl isEqualToString:@"<null>"]) { [statusCell.imageCellTL setFrame:CGRectZero]; statusCell.imageCellTL.image = [UIImage imageNamed:@"Placeholder"] ; }else [statusCell.imageCellTL setImage:img]; 这工作正常,但当它似乎移动滚动和查看图像仍在加载,他们正在改变几次,直到你得到一张照片。 而且我不喜欢诊断时间轮廓,所以我想以某种方式在后台创build这个NSOperationQueue 也可以展示如何使一个“Imagecache”不需要下载已经下载的图像。 **(状态= Twitter时间轴的NSDictionary)。 编辑:(所有单元格) – (UITableViewCell […]

NSOperation – 强制操作等待其他人dynamic

我想实现一个操作队列,我有以下情况: NSOperation A NSOperation B NSOperation C NSOperation D NSOperationQueue queue 我开始添加A queue 。 在A的执行过程中,我需要从B获取一些数据,而我不能继续使用A直到B返回我需要的数据。 B取决于C和C取决于D也会出现相同的情况。 为了pipe理这个,在每个NSOperation我有这个代码: NSOperation *operation; //This can be A, B, C, D or any other NSOperation [self setQueuePriority:NSOperationQueuePriorityVeryLow]; //Set the current NSOperation with low priority [queue addOperation: operation]; //Add the operation that I want to the queue while(!operation.isFinished && !self.isCancelled){} //I […]

NSOperationQueue串行FIFO队列

是否可以通过将其maxConcurrentOperationCount设置为1来将NSoperationQueue对象用作串行FIFO队列? 我注意到文档状态… 对于最大并发操作数设置为1的队列,这相当于一个串行队列。 但是,不应该依赖于操作对象的串行执行。 这是否意味着FIFO执行不能得到保证?