2016-10-30 25 views
0

我剛剛升級到Swift 3,並在UITableViewController中的以下代碼中獲取錯誤。Swift 3.參數標籤不匹配錯誤

代碼是從窗體返回segue,並且旨在刷新從表單插入新條目的表。這個工作罰款2.2,我已經改變了NSIndexPath到IndexPath

@IBAction func saveTripFormViewList(segue:UIStoryboardSegue){ 
    trips = uiRealm.objects(Trip.self) 
    let indexPath = IndexPath(forRow: trips!.count - 1, inSection: 0) 
    tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Automatic) 
} 

我得到的錯誤是

Argument labels '(forRow:, inSection:)' do not match any available overloads 

如何解決錯誤

回答

1

在斯威夫特3這只是IndexPath任何意見(行:部分:)。

FYI,IndexPath是一個新的值類型(結構),它執行與NSIndexPath(一個類)相同的工作。 (NSIndexPath的初始化程序也發生了變化。)另外,我相信它們是免費橋接的,但請不要在此引用我的意思。

+0

謝謝你。但是,如果將語法更改爲\t let indexPath = IndexPath(Row:trips.count - 1,Section:0)。我仍然收到關於不符合重載的列表的錯誤。 –

+0

@MichaelMoulsdale沒有首都,只有小寫的行和部分 –

相關問題