views:

55

answers:

2

This is a bit of a silly question but I don't know how to get around it.

I am making an iphone app and I am just trying to display a progress wheel while my UITableView is loading. I try to test if the view is loading but I get an error: 'request for member 'loading' is something not a structure or a union'. So, I'm not sure how I am supposed to test for when I should show the wheel. maybe I have mistyped something? I don't know, but I am getting pretty frustrated with this silly problem. So, any help would be appreciated. Thanks!

- (void) updateWheel {

  //curtable is a uitableView
  //wheel is a uiactivityIndicatorView

  if (!curTbl.loading) {       //THE ERROR IS FOR THIS LINE
    [wheel stopAnimating];
  } else {
    [wheel startAnimating];
  }

}
A: 

I'm not sure what you mean with "while my UITableView is loading". Do you mean while it is reloading data from the data source ? Because the UITableView is not involved any loading (and has no member "loading".

If you do [myTableView reloadData] then it is querying its dataSource. See the documentation of UITableViewDataSource protocol.

So YOU are responsible for loading data and then informing the table view that something in the data source has changed, and thus you should know when you are still loading data for your data source implementation :-)

DarkDust
Okay, thanks - I was just imitating code from a webview and they have a loading variable. And since I am loading my table with data from the internet, I just assumed it would be the same. But of course, it is not! So now when my table starts building, I stop the spinner. Works beautifully. So, thank you!
Rossi
+1  A: 

There is no loading property of a UITableView, which would be why you are getting a compile error on that line of code. As DarkDust said, you use a data source protocol to feed data into the cells of a table view. As views come into view, the system requests the cell and data via this delegate, and you provide the cell formatting and data in these protocol methods.

BP
Cool - yeah, that works better. Thanks!
Rossi