Method has different argument names from those required

In my ListDetailViewController, I have the following defined.

protocol ListDetailViewControllerDelegate: class {
func listDetailViewControllerDidCancel(controller: ListDetailViewController)
func listDetailViewController(controller: ListDetailViewController, didFinishAddingChecklist checklist: Checklist)
func listDetailViewController(controller: ListDetailViewController, didFinishEditingChecklist checklist: Checklist)
}

In my AllListViewController, I’ve ensured that the class conforms to the protocol and was able to implement the first method:

fun listDetailViewControllerDidCancel(controller: ListDetailViewController)

When I try to implement the method for Adding a checklist written like so:
func listDetailViewController(controller: ListDetailViewController, didFinishAddingChecklist checklist: Checklist) {
<#code#>
}
I get the following error message:
Method ‘listDetailViewController(:didFinishAddingChecklist:)’ has different argument names from those required by protocol ‘ListDetailViewControllerDelegate’ ('listDetailViewController(:didFinishEditingChecklist:)’)

When I try to implement the method for editing a checklist written like so:
func listDetailViewController(controller: ListDetailViewController, didFinishEditingChecklist checklist: Checklist) {
<#code#>
}
I get the following:
Method ‘listDetailViewController(:didFinishEditingChecklist:)’ has different argument names from those required by protocol ‘ListDetailViewControllerDelegate’ ('listDetailViewController(:didFinishAddingChecklist:)’)

Oddly enough I’m using the autocomplete functionality in Xcode, so I know i’m not typing anything wrong and I’ve tried copy/pasting from where I defined the protocol to the ListDetailViewController implementation.

No matter what I do Xcode will not allow me to enter these two methods. Am I missing something?

Hmm, strange. What version of Xcode are you using?

I’ve experienced this too (in Xcode 7; I don’t know if 8 has this issue). It’s not you, it’s Xcode.

When I’ve had this issue, I find it’s usually resolved itself once all the required functions have been declared (and I usually do that before I write any code inside them, except for returning dummy values, just to make sure it builds). But it is frustrating in the meantime.

If you’re experiencing this in Xcode 8, file a bug with Apple, so they can make sure it’s addressed.

I am running Xcode 7, I believe 7.3.1. I’ll try implementing all the methods later and seeing if that fixes the issue. Since I’m working through the tutorials I grabbed the source code that came with the book, opened it and ran it just fine so it is clearly something in my project that Xcode isn’t liking, even tried copy pasting from the source code file into my file to ensure I hadn’t made some silly mistake, and still got the same error.

Thanks for the input.

@narrativium writing all the methods did make the error go away. Seems so silly now that I just didn’t try that to begin with. It’s so easy to get caught up on errors and wanting to fix them before moving on to the next thing, even when you know there shouldn’t be an error! Lesson learned.

When I encounter ‘oddities’ such as you described after a copy/paste scenario, I will delete the code that was copy-pasted and then copy-paste the same code into TextEdit to determine if any non-visible characters are present. Upon seeing the non-code characters (if any) they can be deleted and then the ‘clean’ code can be copied back into your project. This has worked for me in the past.

I generally do the same. In this case I copy/pasted as a way to ensure that my typed code didn’t have any errors as the error popped up from my typed code. Actually the error remained from my copy/pasted code as well, so seems Xcode was just confused. I was able to un-confuse Xcode after I implemented the other method from the protocol.