Question

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!

Was it helpful?

Solution

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).

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top