Select 来自 CloudKit 记录的创建日期

Select creationDate from CloudKit record

我正在尝试用标题和副标题填充单元格。带有字段的标题和带有记录中 CreationDate 的详细信息。

我正在尝试以下操作,但我没有成员 'ObjectForKey'

var objects = CKRecord

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let reuseIdentifier = "Cell"
    var cell:UITableViewCell? = tableView.dequeueReusableCellWithIdentifier(reuseIdentifier) as UITableViewCell?
    if (cell != nil) {
        cell = UITableViewCell(style: UITableViewCellStyle.Subtitle, reuseIdentifier: reuseIdentifier)
    }

    let object = objects[indexPath.row]
    cell!.textLabel!.text = object.objectForKey("Notes") as? String
    cell!.detailTextLabel?.text = object.creationDate.objectForKey("Notes") as? String
    return cell!
}

错误来自这一行:

cell!.detailTextLabel?.text = object.creationDate.objectForKey("Notes") as? String

出于某种原因,您试图从记录的创建日期(即 NSDate.

获取 "Notes" 键

只需将 creationDate 作为 NSDate。然后使用 NSDateFormatter 将日期格式化为可以分配给 detailTextLabel.text.

的字符串