Looks like you are confusing many things here.
You declare a struct to define the template of data. You will not assign values (except default initialization) in the struct declaration.
typealias DictionaryValue = [Int : String] // Key is an Int, value a String
struct SomeStruct {
var opened = Bool()
var title = String()
var sectionData = DictionaryValue()
}
You have to do it in each instance of the struct that you create.
So you have define the dataSource for your table:
var tableViewData = [SomeStruct]()
You say the dictionary is defined in a different file. You mean a file of the XCode project or a file on iPhone ?
Anyway, you have in viewDidLoad, you have to set the content of this array (you will update if you add, remove, change, move a cell
Something like
tableViewData = [SomeStruct(opened: false, title: "Title1", sectionData: [1:"Cell1", 2:"Cell2"]),
SomeStruct(opened: false, title: "Title2", sectionData: [1:"Cell3", 4"Cell4"]), // No key 2 here may be
SomeStruct(opened: false, title: "Title3", sectionData: [1:"Cell5", 2:"Cell6"]),
SomeStruct(opened: false, title: "Title4", sectionData: [1:"Cell7", 3:"Cell8"])] // No key 2 here maybe
Note:
let someDictionary = ["String":"String"]
is incorrect and will not compile
Note: you have content named Cell1, Cell2: I don't understand why you refer to cells here, but let's look at it just as Strings.
In the same way, how do you want to define keys ?
Then in the delegate func cellForRowAt, you will use the dataSource to populate the cell, like below
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "CellItem", for: indexPath)
let myCellData = tableViewData[IndexPath.row] // I assume you have only one section
// Configure the cell...
cell.textLabel!.text = myCellData.title
cell.detailTextLabel?.text = myCellData.sectionData[1) ?? "" // I use key 1, but it may not exist hence ??
return cell
}
So, please explain better what you want to do, in terms of data content, because I am forced to guess too many things.