12 Nov 2008, 05:42
Generic-user-small

John Bickerstaff (13 posts)

I get a warning on lesson 3 when I declare the IBOutlet UITableView *tableView; in the RecipesViewController.h file.

The warning comes on the cellForRowAtIndexPath and didSelectRowAtIndexPath methods… Surprisingly, not on the addNewRecipeNamed method.

The error says: warning: local declaration of ‘tableView’ hides instance variable. The code builds and runs - and I noticed 2 warnings in XCode right at that point in the lesson (33.48) and since I get two also at that point, I was wondering if Bill knows about this off the top of his head…?

I’m stumped - I’m guessing I’ve fat-fingered something somewhere, but I can’t figure out what…

I did indeed follow the instructions and drag from the File’s Owner to the table view and select “tableView” as the Outlet… on the RecipesViewController.xib…

Is this a non-issue? I prefer my code to compile with no warnings, but I’m an Obj-C newbie…

Thanks…

12 Nov 2008, 18:41
Generic-user-small

Bill Nalen (13 posts)

It’s because you have a class variable named tableView and you have a local variable from the method declaration called tableView. The compiler picks the local variable but warns that you might have meant the class variable.

Typically you want to give your class variable a better name, like recipeTableView instead of the generic tableView. But since this is a simple example, just change the method name to use tv instead of tableView in the cellForRowAtIndexPath method. Then just make sure you are referencing the correct UITableView in the code.

12 Nov 2008, 23:15
Generic-user-small

John Bickerstaff (13 posts)

Thanks! Will implement that…

  You must be logged in to comment