听起来,根据您解释的业务逻辑,除了您要呈现的数据列表之外,一切都是共同的。您可以在UITableViewController
子类上公开一个属性来设置您的 tableview 呈现的业务对象:
@interface JTBusinessesTableViewController : UITableViewController
@property (nonatomic, strong) NSArray *businesses;
@end
实例化此类的代码将设置业务对象:
JTBusinessesTableViewController *businessListings; //Instantiate from XIB or Storyboard
businessListings.businesses = [self bookmarkedBusinesses];
[self.navigationController pushViewController:businessListings animated:YES]
显示所有业务的代码不会有太大不同:
JTBusinessesTableViewController *businessListings; //Instantiate from XIB or Storyboard
businessListings.businesses = [self allBusinesses]; // Here we assign all of them
[self.navigationController pushViewController:businessListings animated:YES]
您只是有选择地为该视图控制器提供要显示的业务对象。