NSIndexPath 初始化在 Swift3 中有何变化? [英] How has the NSIndexPath initialization changed in Swift3?
问题描述
我正在尝试跟随 Apple 的 开始开发 iOS 应用程序 (Swift) 教程 并已基本完成.由于我使用的是 Xcode 8(我认为它使用 Swift 3 而不是 Swift 2),我不得不修改教程的几个部分.但是,我遇到了以下编译器错误,我不知道为什么:
I'm trying to follow along with Apple's Start Developing iOS Apps (Swift) tutorial and have almost completed it. I have had to amend several parts of the tutorial as I'm using Xcode 8 (which I think uses Swift 3 instead of Swift 2). However, I am running into the following compiler error and I don't know why:
参数标签(forRow:, inSection)不匹配任何可用的重载
在以下函数中:
@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)
}
}
我猜测 NSIndexPath 有一个不同的初始化器,它在 Swift 3 中发生了变化,但我找不到它.我做错了什么吗?
I'm guessing that there is a different initialiser for NSIndexPath that's changed in Swift 3 but I can't find it. Am I doing something wrong?
谢谢,
推荐答案
NSIndexPath
已更改为 IndexPath
尝试 IndexPath(row: Int, section: Int)
这篇关于NSIndexPath 初始化在 Swift3 中有何变化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!