我回顾我的一些代码,我突然意识到,这有UITableView
,是这个UITableView
的datasource
和delegate
没有声明的协议<UITableViewDataSource, UITableViewDelegate>
,而只是有方法,但从来没有一个UIViewController宣布的协议。UIViewController作为数据源和UITableView的委托而不遵守协议?
这是如何工作的,甚至每?文档:
dataSource
The object that acts as the data source of the receiving table view.
@property(nonatomic, assign) id<UITableViewDataSource> dataSource
Discussion
The data source must adopt the UITableViewDataSource protocol. The data source is not retained.
delegate
The object that acts as the delegate of the receiving table view.
@property(nonatomic, assign) id<UITableViewDelegate> delegate
Discussion
The delegate must adopt the UITableViewDelegate protocol. The delegate is not retained.
有任何类型的任何警告,我当然有必要的方法,使这项工作,一切完美的作品,这是为什么加工?。我不是从我知道的UITableViewController
继承这个协议,这只是一个UIViewController
子类。
编辑:显然IB不会给你任何警告,如果它设置在那里,它尽可能按代码执行。我相信IB也应该给你警告,但我想不是。
它试图从代码尝试时发出预期的警告,但是从IB完成时没有,我认为它也应该在IB中显示警告,但我猜不是。 –
@OscarGomez我同意,它应该在IB中显示警告。 – jbat100