Uiviewcontroller 错误消息";对成员‘的模糊引用;TableView(“:numberOfRowsSection”);

Uiviewcontroller 错误消息";对成员‘的模糊引用;TableView(“:numberOfRowsSection”);,uiviewcontroller,tableview,Uiviewcontroller,Tableview,我有一个UIViewController,我在其中嵌入了一个UITableView 在我创建的ViewController上: @IBOutlet var tableView: UITableView! 然后通过将此属性拖动到表视图,将其链接到IB中 然后我将代理和协议链接回ViewController 但是错误消息“对成员的表视图(\uuU4:numberOfRowsSection)的引用不明确”不断出现 我相信解决办法应该很简单,但我真的无法做到。 出了什么问题 代码: import

我有一个
UIViewController
,我在其中嵌入了一个
UITableView

在我创建的ViewController上:

@IBOutlet var tableView: UITableView!  
然后通过将此属性拖动到
表视图
,将其链接到IB中

然后我将代理和协议链接回
ViewController

但是错误消息“对成员的表视图(\uuU4:numberOfRowsSection)的引用不明确”不断出现

我相信解决办法应该很简单,但我真的无法做到。 出了什么问题

代码:

import UIKit

import CoreData

class BG006bViewControllerMain: UIViewController {

    @IBOutlet var tableView: UITableView!
注:NumberOfSection、numberOfRowsInSection、cellForRowAt-所有这些都没有问题

2019年12月29日增加:增加以下内容,希望能使我的问题更清楚,并回应收到的评论: 问题从这里开始:

// MARK: - NSFetchedResultsControllerDelegate methods

import UIKit

import CoreData

class BG006bTableViewController: UIViewController,UITableViewDataSource, UITableViewDelegate, NSFetchedResultsControllerDelegate  {

    func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>){
        tableView.beginUpdates()
    } **error - Ambiguous.......**

    func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?){

        switch type {
        case .insert:
            if let newIndexPath = newIndexPath {
                tableView.insertRows(at: [newIndexPath], with: .fade) **error - Ambiguous.......**
            }
        case .delete:
            if let indexPath = indexPath {
                tableView.deleteRows(at: [indexPath], with: .fade)
            } **error - Ambiguous.......**
        case .update:
            if let indexPath = indexPath {
                tableView.reloadRows(at: [indexPath], with: .fade)
        } **error - Ambiguous.......**


        default:
            tableView.reloadData()
        } **error - Ambiguous.......**


        if let fetchedObjects = controller.fetchedObjects{
            BG006b = fetchedObjects as! [BGTest006bClass]
        }
    }

    func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        tableView.endUpdates()
    } **error - Ambiguous.......**
//标记:-NSFetchedResultsControllerDelegate方法
导入UIKit
导入CoreData
BG006bTableViewController类:UIViewController、UITableViewDataSource、UITableViewDelegate、NSFetchedResultsControllerDelegate{
func controllerWillChangeContent(\ucontroller:NSFetchedResultsController){
tableView.beginUpdate()
}**错误-不明确**
func控制器(controller:NSFetchedResultsController,didChange anObject:Any,在indexPath:indexPath?处,对于类型:NSFetchedResultsChangeType,newIndexPath:indexPath?){
开关类型{
案例.插入:
如果让newindepath=newindepath{
tableView.insertRows(位于:[newIndexPath],带:.fade)**错误-不明确**
}
案例.删除:
如果让indexPath=indexPath{
tableView.deleteRows(位于:[indexPath],带:.fade)
}**错误-不明确**
案例。更新:
如果让indexPath=indexPath{
tableView.reloadRows(位于:[indepath],带:.fade)
}**错误-不明确**
违约:
tableView.reloadData()
}**错误-不明确**
如果让fetchedObjects=controller.fetchedObjects{
BG006b=获取对象为![BGTest006bClass]
}
}
func controllerDidChangeContent(\控制器:NSFetchedResultsController){
tableView.endUpdates()
}**错误-不明确**

由于错误引用了
numberOfRowsSection
,也许您应该在问题中包含该代码。您好,我如何在此处包含该代码?我尝试过编辑该问题,但我认为这不是正确的方法。我对StackOverflow非常陌生,因此非常摸索。抱歉,谢谢。
     let cellIdentifier = "BGTest006b"

     //let cell = tableView.dequeuReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! CustomViewCell

     let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath) as! BG006bTableViewCell

     cell.name1_Label.text = BG006b[indexPath.row].name1
     cell.name2_Label.text = BG006b[indexPath.row].name2
     cell.name3_Label.text = BG006b[indexPath.row].name3
     return cell
}
// MARK: - NSFetchedResultsControllerDelegate methods

import UIKit

import CoreData

class BG006bTableViewController: UIViewController,UITableViewDataSource, UITableViewDelegate, NSFetchedResultsControllerDelegate  {

    func controllerWillChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>){
        tableView.beginUpdates()
    } **error - Ambiguous.......**

    func controller(_ controller: NSFetchedResultsController<NSFetchRequestResult>, didChange anObject: Any, at indexPath: IndexPath?, for type: NSFetchedResultsChangeType, newIndexPath: IndexPath?){

        switch type {
        case .insert:
            if let newIndexPath = newIndexPath {
                tableView.insertRows(at: [newIndexPath], with: .fade) **error - Ambiguous.......**
            }
        case .delete:
            if let indexPath = indexPath {
                tableView.deleteRows(at: [indexPath], with: .fade)
            } **error - Ambiguous.......**
        case .update:
            if let indexPath = indexPath {
                tableView.reloadRows(at: [indexPath], with: .fade)
        } **error - Ambiguous.......**


        default:
            tableView.reloadData()
        } **error - Ambiguous.......**


        if let fetchedObjects = controller.fetchedObjects{
            BG006b = fetchedObjects as! [BGTest006bClass]
        }
    }

    func controllerDidChangeContent(_ controller: NSFetchedResultsController<NSFetchRequestResult>) {
        tableView.endUpdates()
    } **error - Ambiguous.......**