When I am writing code for finding an item from the array with the use of indexOf it shows me the above stated error. Here is my code:-
func addItemViewController(controller: AddItemViewController, didFinishEditingItem item: ChecklistItem) { if let index = items.indexOf(item) { let indexPath = NSIndexPath(forRow: index, inSection: 0) if let cell = tableView.cellForRowAtIndexPath(indexPath) { configureTextForCell(cell, withChecklistItem: item) } }
In order to use indexOf
the ChecklistItem
must adopt Equatable protocol. Only by adopting this protocol the list can compare an item with other items to find the desired index
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With