在swift库中覆盖方法不起作用

时间:2017-07-24 17:02:08

标签: swift3 realm

我正在使用库“RealmSearchViewController”并覆盖方法。但是调用视图控制器中的方法不是练习。而是执行库中的代码,它打印出一条消息“你需要实现searchViewController(controller:,cellForObject object:,atIndexPath indexPath :)”。我的代码如下所示(我拿出了一些无关的代码)

import UIKit
import RealmSwift
import RealmSearchViewController

class SearchController: RealmSearchViewController {




    override func searchViewController(_ controller: RealmSearchViewController, cellForObject object: Object, atIndexPath indexPath: IndexPath) -> UITableViewCell {
    let record = object as? WorkorderRecord
    let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath) as! WorkorderCell
....
    return cell
}

以下是图书馆的原型:

    open func searchViewController(_ controller: RealmSearchViewController, cellForObject object: Object, atIndexPath indexPath: IndexPath) -> UITableViewCell {

    print("You need to implement searchViewController(controller:,cellForObject object:,atIndexPath indexPath:)")

    return UITableViewCell()
}

1 个答案:

答案 0 :(得分:1)

仔细检查您是否在故事板或笔尖中使用SearchController