回调原类中的函数
我在网上找到了一些有用的信息,但我仍然无法自己做到这一点;)
好吧,让我把我的问题放在上下文中:
我有一个一流的(myViewController),其声明如下:
// i just give you relevant information
RssParser *rssParser;
UIActivityIndicator *activityIndicator;
在我的viewDidLoad中方法 (myViewController) 我有:
//once again, I summarize it for you
[activityIndicator startAnimating];
[rssParser parse];
现在,假设您使用的是 parserDidEndDocument 方法(位于 RssParser 类中),我该如何停止 ActivityIndicator 的动画?如何从 RssParser 类访问我的活动 Indicator 实例?
希望我说清楚了;)
谢谢大家!
戈捷
I found some useful information on the web but I still can't manage to do it by myself ;)
Ok, let me put my problem in context for you :
I have a first class (myViewController) whose declaration is below :
// i just give you relevant information
RssParser *rssParser;
UIActivityIndicator *activityIndicator;
In my viewDidLoad method (myViewController) I have :
//once again, I summarize it for you
[activityIndicator startAnimating];
[rssParser parse];
Now, suppose you are in the parserDidEndDocument method (which is in RssParser class), how am I suppose to stop the animation of the activityIndicator ? How can I get access to my instance of activity Indicator from the RssParser class ?
Hope I made myself clear ;)
Thanks guys!
Gauthier
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
执行此操作的常见方法是使用委托。检查 RssParser 类以了解委托的使用或自己实现一个。在
MyViewController
中将rssParser
的委托设置为self。现在您可以使用MyViewController
实现文档解析后调用的方法。如果您为activityIndicator
创建 ivar,那么您可以轻松地再次访问activityIndicator
。A common way to do this is to use a delegate. Check the
RssParser
class for the use of a delegate or implement one yourself. Set the delegate ofrssParser
to self inMyViewController
. Now you can implement the method that is called after the document is parse withMyViewController
. If you create an ivar foractivityIndicator
then you can easily accessactivityIndicator
again.