how to configure data source of collectionView inside tableViewCell and the tableViewCell grouped by sections

I was do that by tag property for collectionview in each tableviewRow, but now when I grouped tableviewRows inside section, I feel confused!!! any help please!

Accepted Reply

You need to think logically about your data hierarchy.


If I understand well:

You have a tableView with sections

In each section you have several rows

In each row, you have a collection view.


Is it exact ?


If so, I would organize data like this (you can find better names, but they should be easy to understand):

for a row: an array to contain the data for items of cellection view

typealias ArrayForRow = [ItemOfCollectionView]


For a section: an array of ArrayForRow

typealias ArrayForSection = [ArrayForRow]


And finally, the table: an array of ArrayForSection: that is the dataSource

typealias ArrayForTable = [ArrayForSection]


So, your data are

var dataSource : ArrayForTable


Take care when you initialize.


Now, to get the item collItem, in row nRow of section sect, you will call

dataSource[sect] [nRow] [collItem]


Hope that helps.

Replies

You need to think logically about your data hierarchy.


If I understand well:

You have a tableView with sections

In each section you have several rows

In each row, you have a collection view.


Is it exact ?


If so, I would organize data like this (you can find better names, but they should be easy to understand):

for a row: an array to contain the data for items of cellection view

typealias ArrayForRow = [ItemOfCollectionView]


For a section: an array of ArrayForRow

typealias ArrayForSection = [ArrayForRow]


And finally, the table: an array of ArrayForSection: that is the dataSource

typealias ArrayForTable = [ArrayForSection]


So, your data are

var dataSource : ArrayForTable


Take care when you initialize.


Now, to get the item collItem, in row nRow of section sect, you will call

dataSource[sect] [nRow] [collItem]


Hope that helps.