在外部类中执行tableView.reloadData() [英] do tableView.reloadData() in external class

查看:72
本文介绍了在外部类中执行tableView.reloadData()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从外部类进行解析查询.该查询返回了用于填充tableview的数组,因此在viewDidLoad方法中,我调用MyClass.load(array),异步解析方法findObjectInBackground返回给我填充的数组,但在findObject检索到对象时tableView已经创建,并且我看到一个空的tableView,我对它进行了快速Google搜索,发现我必须使用self.tableView.reloadData()方法,我尝试了一下,但是我在一个外部类中,并且是tableView的委托在tableViewController中,有什么方法可以从外部类刷新tableView吗? 如果您需要一些代码示例,请问一下,谢谢!

I am doing a Parse query from an external class. This query give me back the array for populate the tableview, so in the viewDidLoad method I call MyClass.load(array) and the async parse method findObjectInBackground return me the array filled but in the time that the findObject retrive me the objects the tableView is already created and I see an empty tableView, I did a fast google search for the problem and I found that I have to use the self.tableView.reloadData() method, I tried it but I am in an external class and the delegate for the tableView is in the tableViewController, there is any way to refresh the tableView from an external Class? If you need some code example just ask it, thank you!

EDIT 我正在使用Swift 2.0

推荐答案

您需要在外部类和ViewController之间设置自定义委托.

You need to set custom delegate between your external class and ViewControllers.

检查是否创建自定义委托

此外,您可以使用NSNotificationCenter发送和发布通知.请检查链接

Also, you can use NSNotificationCenter for send and post notifications. please check link

这篇关于在外部类中执行tableView.reloadData()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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