简体   繁体   中英

Reload tableView data in rootViewController

I am trying to get my tableView in rootViewController to reload after I create a new object in the array that populates it.

I want to use the following in my viewDidLoad of rootVIewController:

[tableView reloadDate];

but I get the error:

Use of undeclared identifier "tableView"

I think it's because I haven't declared the object tableView until after the viewDidLoad method. So what other options do I have to refresh the table?

Thanks

If you haven't declared the tableView, than you cannot tell it to reload. There is something of a question surrounding the architecture of your application: When you say 'rootViewCOntroller' - is that referring to the applications RVC? If so, are you instantiating the tableView programmatically, or accessing it from a .xib/outlet?

If you're accessing a XIB, you should be calling your property outlet [[self tableView] reloadData].

If you're creating the table view programmatically, you should create it before you call reload on it -- and in most cases, you'll want to define a property on your RVC class pointing to that tableView, such that you'd still be calling [[self tableView] reloadData] as opposed to accessing it directly as you've done in your code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM