views:

267

answers:

3

I am trying to use CoreData to populate a UITableView. I have been using the developer "Locations" project, and I think I have everything correct. But, now I am getting the following error when I build:

request for member 'tableView' in something not a structure or union

Why would it be confused about tableView? I am using it many times in the methods. The errors seem to be coming from:

[self.tableView insertRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
[self.tableView scrollToRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] atScrollPosition:UITableViewScrollPositionTop animated:YES];

Ideas?

A: 

What is self and why do you need to use it there?

If you are in a class with a member named tableView, probably the only time you need to access it using self is when you create it to allow your @property (retain) to take effect. Sure it's not a bad idea to make accesses to members explicitly clear either.

(edit for eman - no worries!)

Adam Eberbach
`self.tableView` simply means that you're using the accessor, rather than directly accessing the ivar. It's generally good practice to always use accessors, especially (as in this case) when you're accessing a property in a superclass that you don't control.
eman
Sorry, I may have misread your answer (I'll un-downvote it if you edit it). Still, it's almost certainly a good idea to use the accessor in this case.
eman
A: 

Are you sure you're properly subclassing UITableViewController? As in,

@interface MyTableViewController : UITableViewController {}

EDIT: As Rob Lourens says, your problem is that you're subclassing UIViewController instead of UITableViewController. UIViewController has a generic view property, but no table view--use it for any situation where you don't need to manage a table view, and use UITableViewController for any situation where you do.

eman
It looks like it to me. @interface MyRidesViewController : UIViewController <CLLocationManagerDelegate> {}
Nic Hubbard
You need to subclass `UITableViewController`, not `UIViewController`.
Rob Lourens
A: 

That error tends to show up when you use dot-syntax in less than clear situations.

First, I would try changing it to [self tableView] and see if the issue goes away.

As for why it is occurring only in this method, more code would need to be shown to narrow down the specific issue.

Marcus S. Zarra