UITableView with controller separate from ViewController

前端 未结 5 1791
感情败类
感情败类 2020-12-22 03:06

I\'m a newbie to Swift and XCode, taking a class in iOS development this summer. A lot of projects we\'re doing and examples I\'m seeing for UI elements like PickerViews, Ta

5条回答
  •  無奈伤痛
    2020-12-22 03:29

    You are trying to set datasource and delegate of UITableView as UITableViewController. As @Ahmad mentioned its more understandable in same class i.e. ViewController, you can take clear approach separating datasource and delegate of UITableView from UIViewController. You can make subclass of NSObject preferably and use it as datasource and delgate class of your UITableView.

    You can also also use a container view and embed a UITableViewController. All your table view code will move to your UITableViewController subclass.Hence seprating your table view logic from your View Controller

    Hope it helps. Happy Coding!!

提交回复
热议问题