ios – XCode error “Can not convert worth of kind ‘NSIndexPath’ to anticipated component kind ‘Array.ArrayLiteralElement’ (aka ‘IndexPath’)”

[ad_1]

I’m new to XCode and I’m following a web-based tutorial for a procuring record program. I’ve this error that seems twice, “Can not convert worth of kind ‘NSIndexPath’ to anticipated component kind ‘Array.ArrayLiteralElement’ (aka ‘IndexPath’)”.

The tutorial I am following is right here in the event you want it: https://code.tutsplus.com/tutorials/ios-from-scratch-with-swift-building-a-shopping-list-application-2–cms-25516

If anybody is ready to assist me out or give me some steering that might be tremendously appreciated, thanks!

func controller(controller: AddItemViewController, didSaveItemWithName title: String, andPrice value: Float) {
// Create Merchandise
let merchandise = Merchandise(title: title, value: value)
 
// Add Merchandise to Gadgets
gadgets.append(merchandise)
 
// Add Row to Desk View
tableView.insertRowsAtIndexPaths([NSIndexPath(forRow: (items.count - 1), inSection: 0)], withRowAnimation: .None)
// The road above is the place the error happens
// Save Gadgets
saveItems() }

and the second error which is identical error message is right here:

    // Fetch Index for Merchandise
    if let index = gadgets.firstIndex(of:merchandise) {
      // Replace Desk View
      tableView.reloadRowsAtIndexPaths([NSIndexPath(forRow: index, inSection: 0)], withRowAnimation: .Fade)
     // The road above is the place the error happens
    }
     
    // Save Gadgets
    saveItems()

Thanks upfront!

[ad_2]

Leave a Reply