[CKRecord]类型的值没有成员'对象

时间:2018-03-08 13:09:16

标签: swift3

我在控制器之间在CloudKit上发送书籍记录以显示值,但它一直说明[CKRecord]类型的值没有成员'对象'。

import UIKit
import CloudKit

class FamilyDetailViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

@IBOutlet var bookImageView: UIImageView!
@IBOutlet var tableView:UITableView!
var book:[CKRecord] = []


override func viewDidLoad() {
    super.viewDidLoad()

    print(book)
}



override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) ->
    Int {
        return 4
}

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! FamilyDetailTableViewCell

    switch indexPath.row {
    case 0:
        cell.fieldLabel.text = "Name"
        **cell.valueLabel.text = book.object(forKey: "name") as? String
    case 1:
        cell.fieldLabel.text = "Author"
        cell.valueLabel.text = book.object(forKey: "author") as? String
    case 2:
        cell.fieldLabel.text = "Date"
        cell.valueLabel.text = book.object(forKey: "dateofpurchase") as? String
    case 3:
        cell.fieldLabel.text = "Note"
        cell.valueLabel.text = book.object(forKey: "note") as? String
    default:
        cell.fieldLabel.text = ""
        cell.valueLabel.text = ""
    }

    cell.backgroundColor = UIColor.clear
    return cell
}


@IBAction func close(segue:UIStoryboardSegue) {

  }

}

尝试打印(书籍)并且记录似乎正确如下,但只是不能使值显示在表格视图中。

  

打印结果(书):

     

值= {       作者="测试2作者&#34 ;;       dateofpurchase ="测试2日期&#34 ;;       image ="&#34 ;;       name =" test 2&#34 ;;       note ="&#34 ;; }

0 个答案:

没有答案