Hi everyone
I am new to XCode and I am following an online tutorial for a shopping list program. I have this error that appears twice, "Cannot convert value of type 'NSIndexPath' to expected element type 'Array.ArrayLiteralElement' (aka 'IndexPath')".
The tutorial I'm following is here if you need it: https://code.tutsplus.com/tutorials/ios-from-scratch-with-swift-building-a-shopping-list-application-2--cms-25516
If anyone is able to help me out or give me some guidance that would be greatly appreciated, thank you!
// MARK: -
// MARK: Add Item View Controller Delegate Methods
func controller(controller: AddItemViewController, didSaveItemWithName name: String, andPrice price: Float) {
// Create Item
let item = Item(name: name, price: price)
// Add Item to Items
items.append(item)
// Add Row to Table View
tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: (items.count - 1), inSection: 0)], withRowAnimation: .None)
// The line above is where the error occurs
// Save Items
saveItems()
}
// MARK: -
// MARK: Edit Item View Controller Delegate Methods
func controller(controller: EditItemViewController, didUpdateItem item: Item) {
// Fetch Index for Item
if let index = items.firstIndex(of:item) {
// Update Table View
tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: index, inSection: 0)], withRowAnimation: .Fade)
// The line above is where the error occurs
}
// Save Items
saveItems()
}