swift 3未调用的函数

swift 3未调用的函数,swift,Swift,当我点击addFavoriteButton时,除了fav.tableview.insertRows函数之外,所有的东西都会被调用,它不会崩溃或者给我一个错误,但是它不会被调用,因为如果它被调用,它应该做的第一件事就是在控制台中打印一些东西 类收藏夹:UITableViewController{ var wrds1: manager_class = manager_class() var store: Store! //var tableCell = TableViewCell() var

当我点击
addFavoriteButton
时,除了
fav.tableview.insertRows
函数之外,所有的东西都会被调用,它不会崩溃或者给我一个错误,但是它不会被调用,因为如果它被调用,它应该做的第一件事就是在控制台中打印一些东西


类收藏夹:UITableViewController{

var wrds1: manager_class = manager_class()

var store: Store!

//var tableCell = TableViewCell()
var copiedarray1 = [String]()
//let cell1: TableViewCell = TableViewCell()



override func numberOfSections(in tableView: UITableView) -> Int {
    return 1
}

override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    print("i am inside table view!")
    let cell = tableView.dequeueReusableCell(withIdentifier: "TableViewCell", for: indexPath) as! TableViewCell
    print(wrds1.favorite_words.isEmpty)
    print("Heloo")


    let word = wrds1.favorite_words[indexPath.row]
    cell.favoriteWordInTable?.text = word


    return cell
}



override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {

    return copiedarray1.count
}
override func tableView(_ tableView: UITableView, titleForFooterInSection section: Int) -> String? {
    let title = "favorites"
    return title
}
override func viewDidLoad() {


    let wrds: ViewController = ViewController()
    //let wrds1: manager_class = manager_class()

    copiedarray1 = wrds.copiedarray



}

}

将鼠标光标指向要调用的函数的左侧,应该有一个圆点,如果您的按钮连接到此函数,当您单击该圆点时,应该会看到弹出列表中显示的按钮


您的问题应该是代码和情节提要之间的连接,或者仅在情节提要上。

您正在使用
wrds.copiedarray
中的
numberofrowsin节

wrds1.
cellForRow
中最喜欢的单词

我想您必须像这样更改章节中的
行数

override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return wrds1.favorite_words.count
}

如果您在If条件中设置断点,并且它没有停在那里,则意味着wrds.favorite_words.index(of:newItem!)为零。只需在控制台中尝试
po wrds.favorite_words.index(of:newItem!)
,然后检查结果。我尝试了断点,它进入了if语句中,它遍历了其中的所有函数,insertRows不起作用,这不是插入新行。什么是
收藏夹
?我将编辑帖子并添加我的收藏夹类。您还需要遵循swift编码惯例。类、结构、枚举和协议需要大写。
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
    return wrds1.favorite_words.count
}