将数据从 NSOperation 传递到下一个 NSOperation [英] Pass data from NSOperation to next NSOperation

查看:65
本文介绍了将数据从 NSOperation 传递到下一个 NSOperation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将数据从 NSOperation 向上传递到依赖链以供下一个 NSOperation 使用?

Is it possible to pass data from an NSOperation up the dependency chain to be used by the next NSOperation?

谢谢

克里斯

推荐答案

是的.当前的 NSOperation 可以通过 dependencies 方法访问它的依赖:

Yes. The current NSOperation can access it's dependancies via the dependencies method:

NSArray *myDependancies = [self dependencies];

然后它可以访问您希望在之前的操作中使用的任何属性并提取它需要的任何数据.

It can then access whatever properties you wish on the previous operations and pull out any data it requires.

在最近的一个项目中,我发现我需要经常传递数据,所以我创建了一个 NSOperation 的子类,它会自动将 NSDictionary 数据从一个操作传送到下一个操作.

In a recent project I found that I needed to pass data along so often that I created a subclass of NSOperation that automatically carried forward an NSDictionary of data from one operation to the next.

这篇关于将数据从 NSOperation 传递到下一个 NSOperation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆