我是新來的Swift,並不擅長操縱json和hash。解析json並用tableview顯示
這裏是我的JSON [網友的陣列]
[
{"name": "mary", "age": 24, "detail": "i love ..."},
{"name": "mark", "age": 28, "detail": "i love ..."}
]
我想先,然後顯示每個用戶的名稱及其age
,如果你點擊有姓名,年齡,它會顯示detail
我只知道如何迭代一個數組並將該值放在單元格中。
喜歡這種方式,但現在知道如何使用字典
cell.textLabel.text = self.items[indexPath.row]
我怎麼能知道哪些key
我應該在每個循環中使用顯示tablecells?
func tableView(invoice: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
我怎麼會知道這個時候,我應該使用name
,下次我應該用age
顯示我的手機?
也許'cell.textLabel.text = self.items [indexPath.row] [ 「名稱」]年齡節目;'? – 2014-10-27 06:12:58
但是如何顯示「年齡」?也許有很多用戶。邏輯看起來如此複雜 – newBike 2014-10-27 06:16:52
那麼你使用''age''而不是''name''。這真的很複雜嗎? – 2014-10-27 06:35:17