ControllerからDataSourceを切り離す
- データソースクラスのヘッダーにUIKitインポート
#import <UIKit/UIKit.h>
- データソースクラスのヘッダーにUITableViewDataSource準拠の宣言
@interface TableDataProvider : NSObject<UITableViewDataSource>
- ViewControllerクラスでデータソースクラスのインスタンスをプロパティで保持
@property(strong, nonatomic) TableDataProvider *dataSource;
- ViewControllerのviewDidLoadなどに以下を記載(ViewControllerのtableviewのデータソースにTableDataProviderのインスタンスを指定)
self.dataSource = [[TableDataProvider alloc]init]; self.tableView.dataSource = self.dataSource;
以上