xcode - Swift 1.2 - 列表类型未声明

标签 xcode swift list object

在我的 TableViewController 中我有这行代码

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

在这个 block 中我尝试获取对象列表

let list = frc.objectAtIndexPath(indexPath) as! List

但我收到这个警告:

Use of undeclared type "List"

有人知道怎么处理吗?

这是完整的代码:

var frc: NSFetchedResultsController = NSFetchedResultsController()

override func tableView(tableView: UITableView,
    cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCellWithIdentifier("Cell",
        forIndexPath: indexPath) as! UITableViewCell
    // Configure the cell...
    let list = frc.objectAtIndexPath(indexPath) as! list
    cell.textLabel?.text = list.name
    cell.detailTextLabel?.text = list.url
    return cell
}

欢迎任何帮助!!

问候和感谢

最佳答案

在本教程中,Jason 在其数据模型文件中创建了一个名为“List”的实体,然后创建了一个名为 List 的类。

以下链接在他创建此文件后立即开始播放视频。 https://youtu.be/GeM7Zw12wbM?t=5m30s

您可能以不同的方式命名您的实体。

我将我的记录命名为记录,因为我正在存储记录。
所以我的代码如下所示:

var frc: NSFetchedResultsController = NSFetchedResultsController()

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

        let cell = tableView.dequeueReusableCellWithIdentifier("Cell",
        forIndexPath: indexPath) as! UITableViewCell

        // Configure the cell...

        // ALL occurrences of "list" are instead "record"
        // ALL occurrences of "List" are instead "Record"

        let record = frc.objectAtIndexPath(indexPath) as! Record
        cell.textLabel?.text = record.name
        cell.detailTextLabel?.text = record.url

        return cell

}

关于xcode - Swift 1.2 - 列表类型未声明,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31479327/

相关文章:

ios - 在 App Store 中为现有的 Live App 购买

swift - 访问另一个 View Controller 中的数组

python - 如何在 python 中将字符串转换为列表?

Python:包含项目的完整列表

ios - 当我更改 ViewController 时 UIImageView 不旋转

python - 使用 Python 反向补充 DNA 链

objective-c - 如何将字典数据添加到数组中?

ios - -[CCSprite draw] 530 中的 OpenGL 错误 0x0502

objective-c - Applescript 和 Cocoa 窗口位置

有序的快速逻辑运算符