且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

iOS和Xcode:在UITableView中设置委托和数据源时出现不兼容的类型错误

更新时间:2023-09-22 11:33:58

您应该声明UITableViewDataSource,这是实现该协议并将数据提供给表的对象.

You should declare a UITableViewDataSource, which is an object that implements that protocol and supplies data to your table.

_tableView.dataSource = self;

来自Apple文档

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.

已更新:请按照答案的第一行定义您的类,如下所示:您应该声明一个UITableViewDataSource:

Updated: Please define your class like below as per my first line in the answer that You should declare a UITableViewDataSource:

@interface BrowserViewController : UIViewController <UITableViewDataSource,UITableViewDelegate>