Why am I getting these errors? alt text http://img39.imageshack.us/img39/2203/help.tif
为什么我会收到这些错误? alt text http://img39.imageshack.us/img39/2203/help.tif
It says:
Error: Request for member "jokeTableView" in something not a struction or union
错误:请求成员“jokeTableView”,而不是struction或union
What does that mean? And why is it breaking. I tried reading about initWithStyle but I just could catch up on it
那是什么意思?为什么它会破裂。我尝试阅读有关initWithStyle但我只能赶上它
Here is my .h file:
这是我的.h文件:
#import <UIKit/UIKit.h>
@interface TableViewController : UITableViewController {
NSMutableArray *jokes;
IBOutlet UITableView *jokeTableView;
}
@property (nonatomic, retain) NSMutableArray *jokes;
@end
Thanks!
2 个解决方案
#1
7
Your object (TableViewController) has no property named jokeTableView.
您的对象(TableViewController)没有名为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,它需要是一个属性。否则,您必须使用符合键值编码的方法或直接使用 - >运算符(或仅将其用作ivar并且不引用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).
但请注意,您在初始化程序中设置了一个插座,但这不起作用。你必须在 - [TableViewController awakeFromNib]方法中设置它,因为当实际调用初始化程序时,self-> jokeTableView将为nil(在将对象序列化为nib文件之前在IB中发生)。
#2
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.
由于您在初始化时执行此操作,因此出口应为NULL,因此此初始化不应执行任何操作。这应该最早在awakeFromNib时完成。
#1
7
Your object (TableViewController) has no property named jokeTableView.
您的对象(TableViewController)没有名为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,它需要是一个属性。否则,您必须使用符合键值编码的方法或直接使用 - >运算符(或仅将其用作ivar并且不引用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).
但请注意,您在初始化程序中设置了一个插座,但这不起作用。你必须在 - [TableViewController awakeFromNib]方法中设置它,因为当实际调用初始化程序时,self-> jokeTableView将为nil(在将对象序列化为nib文件之前在IB中发生)。
#2
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.
由于您在初始化时执行此操作,因此出口应为NULL,因此此初始化不应执行任何操作。这应该最早在awakeFromNib时完成。