如何在Swift3中更改NSIndexPath初始化? [英] How has the NSIndexPath initialization changed in Swift3?

查看:144
本文介绍了如何在Swift3中更改NSIndexPath初始化?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试跟随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)

API参考:indexpath

Swift 3.0开发人员预览版

这篇关于如何在Swift3中更改NSIndexPath初始化?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆