Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Determine if UITableView has static cells or dynamic prototypes programmatically?

I'm writing an abstract UITableViewController class and I'd like to write something in viewDidLoad like

if (self.tableView.contentType == UITableViewContentTypeStaticCells) {
    // Do something when table view has static cells
} else {
    // Do something when table view has dynamic prototypes
}

But obviously there is no contentType on UITableView. Is there a way to determine programmatically whether the tableView's storyboard content is static or dynamic?

like image 887
dmur Avatar asked Nov 21 '13 20:11

dmur


1 Answers

Just for the curious: [tableViewController valueForKey: @"staticDataSource"] will get you there, where tableViewController is a UITableViewController.

BUT(!) this might not pass the AppStore and may break without warning as it's not published API.

Update: It seems that checking if checking, if

self == self.tableView.dataSource

while self is a UITableViewController also gives you re requested result.

like image 154
osxdirk Avatar answered Oct 19 '22 22:10

osxdirk