我正在尝试跟随Apple的开始开发iOS应用程序(Swift)教程并几乎完成它.我不得不修改教程的几个部分,因为我正在使用Xcode 8(我认为使用Swift 3而不是Swift 2).但是,我遇到了以下编译器错误,我不知道为什么:
Argument labels (forRow:, inSection) do not match any available overloads
在以下功能中:
@IBAction func unwindToMealList(sender: UIStoryboardSegue) {
if let sourceViewController = sender.sourceViewController as? MealViewController, meal = sourceViewController.meal {
// Add a new meal
let newIndexPath = NSIndexPath(forRow: meals.count, inSection: 0)
meals.append(meal)
tableView.insertRows(at: newIndexPath, with: .bottom)
}
}
Run Code Online (Sandbox Code Playgroud)
我猜测NSIndexPath有一个不同的初始化程序,它在Swift 3中有所改变但我找不到它.难道我做错了什么?
谢谢,
iOS*_*eek 106
NSIndexPath 已改为 IndexPath
尝试 IndexPath(row: Int, section: Int)