我创建了如下字典,
let bookList = [
["title" : "Harry Potter",
"author" : "Joan K. Rowling"
"image" : image // UIImage is added.
],
["title" : "Twilight",
"author" : " Stephenie Meyer",
"image" : image
],
["title" : "The Lord of the Rings",
"author" : "J. R. R. Tolkien",
"image" : image]
我想用这个书单制作一个tableView。
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
guard let cell = tableView.dequeueReusableCell(withIdentifier: "listCell") as? ListCell else { return UITableViewCell() }
let book = bookList[indexPath.row]
cell.configureCell(title: book.???, author: ???, bookImage: ???)
return cell
}
我应该如何使用 Dictionary 的 value 和 key 来配置 Cell?