【问题标题】:iOS - Passing Values from an Object to it's Containing ClassiOS - 将值从对象传递给它的包含类
【发布时间】:2011-09-15 13:15:52
【问题描述】:

设置:

我有一个 AppDelegate 并在其上声明为 CustomUIViewController.h 并且在该控制器中我声明了 RandomName.h (作为对象,而不是子类) 我可以使用 [super methodName] 或类似名称吗从 RandomName.h 上的方法触发 CustomUIViewController 上的方法?

或者我必须将它传递给 appDelegate,然后再从那里传递给 CustomUIViewController? (我是怎么做到的)

谢谢

附:咖啡不错。

【问题讨论】:

  • 正是在我正在研究的项目中,它是一个为我播放图像序列的类。我试图找到的是另一种将“我完成动画”值从 RandomName 传递回 CustomUIView 的方法,而无需通过 AppDelegate 运行它。
  • 对于查看此线程的任何人,通知中心都可以正常工作。

标签: iphone ios4 super


【解决方案1】:

我想我已经理解了你的问题。请原谅我没有;-)

super 不能这样工作。您可以简单地调用,

[appDelegate.customViewController methodName];

另一种方法是将 customViewController 的引用传递给 RandomName 对象,例如,

[[RandomName alloc] initWithParent:self];

你必须在initWithParent方法中保留self的引用,假设变量名是parent,然后像这样调用方法,

[parent methodName];

【讨论】:

  • 谢谢,这比我现在做的更干净。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-12-20
  • 1970-01-01
  • 2016-02-08
  • 2015-06-15
  • 1970-01-01
相关资源
最近更新 更多