Swift2.0 - Create tableView from an array of tuples

拥有回忆 提交于 2019-12-25 16:27:28

问题


I have an array of tuples that is created from a JSON.

typealias TagAndLocation = (tag: String, location: String)

var resultTuples = [TagAndLocation]()

for (_, subJSON) in json {
    let Tag = subJSON["Tag"].string!
    let Location = subJSON["Location"].string!

    let tagloc = (tag: Tag, location: Location)
    resultTuples.append(tagloc)
}

Then I'll use

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    let cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: "CellConcert")

           //PROBLEM IS HERE. I want the indexPath.row to be the position of the array of tupple
            cell.textLabel?.text = resultTuples.[indexPath.row][]

            return cell

        }

Basically i want my tableView to have the content of concerts.

Any idea? Thanks

来源:https://stackoverflow.com/questions/32100734/swift2-0-create-tableview-from-an-array-of-tuples

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!