Search code examples
objective-ccocoainitwithstyle

Why am I getting an error for this?


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!


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