I am implementing a UITableview and I want to have an array that holds the titles for each section.
let titleOne = "Hello World"
let titleTwo = "What's next"
let titleThree = "Extras"
let headerTitles = [titleOne, titleTwo, titleThree]
This is so that I can access the array in the following method:
override func tableView(tableView: UITableView, titleForHeaderInSection section: Int) -> String? {
return headerTitles[section]
}
However when I try and declare the array as a class variable and add the static strings I get the following error:
'name.Type' does not have a member named 'titleOne'
I have read the following and understand why the above is not possible: 'Class.Type' does not have a member named 'variable' error just a lack of class variable support?
Is there a way to elegantly create the array with the constant strings without using string literals in the array and also without doing it in a method? I am thinking maybe a Struct? Or is this overkill?
Thanks.