Can't assign value of type '[(String)]' to value of type 'String!'?
woodText.text = textForWood["Oak"] as! String
You need to assign String to text
for UITextView
. The above shows how to extract a string from a dictionary.
Add based on comments
I don't think using a dictionary to populate the table view is a good idea. (Remember, dictionaries are not ordered, arrays.) You must have an array that informs the table of how many rows to display and what to display in those rows.
One solution would be an array of dictionaries ( [[String : String]]
). Then you can fill each cell in cellForRowAtIndexPath
. The dictionary for each line should contain something like
["name" : "Oak", "text" : "The text to display in the oak cell..."]
Use the standard template code to delete a cell with a text view and then
let woodDictionary = textForWood[indexPath.row]!
woodText.text = woodDictionary["text"] as! String
source to share