我是一个Objective-C的新手,正在阅读Alasdair Allan的《iPhone编程》。在阅读过程中,我发现了以下代码:
@interface RootController : UIViewController <UITableViewDataSource, UITableViewDelegate> {
UITableView *tableView;
NSMutableArray *cities;
}
// warning: remember this tableView
@property (nonatomic, retain) IBOutlet UITableView *tableView;
相对路径的实现方式如下:
@implementation RootController
@synthesize tableView;
现在:我了解到 @synthesize 是一种省略枯燥的 getters 和 setters 的快捷方式。
但我有一些问题:
- 在实现 tableView 的代码中 从未显式调用,但 dealloc 会释放它;
- 如果它从未被显式调用过,为什么要使用 @synthesize?