简体   繁体   中英

How to call method from UItableview delegate

1) My problem: how to call NumberofRowsInSection of UItableViewDataSource Method of another UItableViewdataSource.

2 ) HOw to make aggrateTableViewDataSource from n number of Different CustomTableViewDataSource?

Need Help. Thanks

I think there is some conceptional confusion in your question.

datasource is a delegate protocol . That means that you can have a class that adopts that protocol. That again means that it has certain required or optional methods, eg tableView:numberOfRowsInSection: in the case of the protocol UITableViewDataSource .

Therefore there is no such thing as "two datasources". If your class that implements the datasource protocol has more than one source for its data, that's a different kind of "data source" - and a question completely unrelated to the datasource protocol for table views.

Of course, you can have more than one UITableView that refers to the same class as its datasource . This is actually common for search tables which typically can display both the original and the search result table. In this case, you check in your datasource methods which table view is requesting the data.

I would suggest to make a model that calculates this from the source, not the tables. If you are using core data, create a class that fetches the objects and calculates the figures then observes changes to update the basis for the figures. Make your aggregate functions output as read only properties. If not core data use, I'd need more info to advise.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM