0

Why am I getting these errors? alt text http://img39.imageshack.us/img39/2203/help.tif

It says:

Error: Request for member "jokeTableView" in something not a struction or union

What does that mean? And why is it breaking. I tried reading about initWithStyle but I just could catch up on it

Here is my .h file:

#import <UIKit/UIKit.h>


 @interface TableViewController : UITableViewController {

NSMutableArray *jokes;
IBOutlet UITableView *jokeTableView; 


 } 

 @property (nonatomic, retain) NSMutableArray *jokes;

 @end

Thanks!

  • The way you access it assumes that jokeTableView is a property of TableViewController. – stefanB May 15 '09 at 02:24
  • Maybe you could try copy/paste just the actual code, small picture is not much use :) Just a cut out of the line in question and maybe relevant lines from header file. – stefanB May 15 '09 at 02:25
  • 2
    maybe it doesn't like your Jokes? (Sorry couldn't resist) :-) – lothar May 15 '09 at 02:27
  • @lothar lol its ok. If I were you, I wouldn't be able to resist that either :p –  May 15 '09 at 02:30

2 Answers2

7

Your object (TableViewController) has no property named jokeTableView.

In order to access jokeTableView with the special dot operator, it needs to be a property. Otherwise you have to access it using Key-Value-Coding compliant methods or directly using the -> operator (or just use it as an ivar and no reference to self):

jokeTableView.delegate = self;

or

self->jokeTableView.delegate = self;

or

[self jokeTableView].delegate = self;

or

@property (retain) UITableView *jokeTableView;
// later...
self.jokeTableView.delegate = self;

Also note, however, that you are setting an outlet in the initializer and this won't work. You'll have to set this in the -[TableViewController awakeFromNib] method since self->jokeTableView will be nil when the initializer is actually called (which happens in IB prior to serializing the object into the nib file).

Jason Coco
  • 77,985
  • 20
  • 184
  • 180
  • Hey jason. lol this has to be about the 3rd time you've helped me this week! thanks man! Ok I added my header file... The thing is, I DO state what jokeTableView is... –  May 15 '09 at 02:25
  • Why do you want me to change it to "self.jokeTableView.delegate = self;" if it was already that? –  May 15 '09 at 02:43
  • And I initialized jokeTableView in awakeFromNib, but now the take view is just blank... It doesn't even display the rows... –  May 15 '09 at 02:50
  • The point of his fourth option is that if you want your current (property) syntax to work you could actually declare it as a propert--as the line just above it shows. – smorgan May 15 '09 at 03:02
  • Oh ok i get it. But then why after I did that, and I initialized with AwakeFromNib, did my tableView not show up? –  May 15 '09 at 03:04
  • If this view is in a nib, why not just set the delegate property there? Isn't UITableView's delegate property an outlet? – Peter Hosey May 15 '09 at 03:05
  • well it is already a delegate... But thats what apples code said to do.. Should I not do that? –  May 15 '09 at 11:09
0

Since you are doing this at init time, the outlets should be NULL, so this initialization shouldn't do anything. This should be done at awakeFromNib time at the earliest.

Mark
  • 6,108
  • 3
  • 34
  • 49