Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does UITableViewController equal to UITableViewDataSource, UITableViewDelegate

Could we use UITableViewDataSource, UITableViewDelegate totally replace UITableViewController, for example, is there difference between these two code lines?

@interface ShareViewController : UITableViewController
@interface ShareViewController : UIViewController<UITableViewDataSource, UITableViewDelegate>
like image 241
yonzhang Avatar asked Dec 09 '25 00:12

yonzhang


1 Answers

There is a BIG difference between these two lines of code. This

@interface ShareViewController : UITableViewController

means that your ShareViewController inherits from UITableViewController, so it provides, for example, an UITableView as main view. This

@interface ShareViewController : UIViewController<UITableViewDataSource, UITableViewDelegate>

means that your ShareViewController is a classic UIViewController (inherits from UIViewController) and simply implements protocols to manage table views.

like image 55
Andrea Mario Lufino Avatar answered Dec 11 '25 20:12

Andrea Mario Lufino



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!