I'm mostly new to iOS and Xcode dev, so I'm just here asking for some handholding for now...
I'm making an app with a TableView of medical symptoms. I've managed to populate the tableview with data from an array and separate that into sections depending medical specialty. However, I've run into a brick wall with regards to being able to checkmark multiple symptoms in the table, and save that for later use in another ViewController.
The easiest method for me to understand is to create a dictionary with the whole list of symptoms, and then assign a boolean value to each of the symptoms depending on whether it is checked or unchecked. But I have no idea how to implement a struct that houses all the data, as well as being able to separate it into sections.
I'm also wondering whether it would be better to just keep all the data in an external file and allow the app to access the data.
I can add the code I've written so far if needed.
Help would be much appreciated!
Below is my current implementation of the data source
let SymptomsSections = ["General", "Respiratory", "Cardiac", "Abdominal", "Neurological", "Psychiatrical"]
let SymptomsList =
[
["Dry mouth", "Malaise", "Asthenia"],
["Dyspnoea", "Wheezing"],
["Orthopnoea", "Angina"],
["Coffee ground vomiting", "Melaena"],
["Agnosia", "Apraxia"]
]
and the code to write it in tableView
override func tableView(_ tableView: UITableView, titleForHeaderInSection section: Int) -> String?
{
return self.SymptomsSections[section]
}
override func numberOfSections(in tableView: UITableView) -> Int
{
return self.SymptomsSections.count
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int
{
return SymptomsList[section].count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
let cell = tableView.dequeueReusableCell(withIdentifier: "SymptomsCell", for: indexPath)
cell.textLabel?.text = SymptomsList[indexPath.section][indexPath.row]
return cell
}