10

I frequently have relatively complicated protocols with associatedType constraints, are used in generics, are used by CoreData type extensions, etc. I therefore relatively frequently get the error: Type .. does not conform to protocol .... I usually can figure this out after a while, but the error message is really unhelpful -- and usually, if the problem is a minor typo in the signature of a method or something, the bug takes a little while to find. With Java interfaces, IDEs will often report something like method ... not implemented or something, so I know which method to look at in closer detail.

is there a way to make Xcode report details about the members of the protocol which are missing from the conforming type?

qqq
  • 1,360
  • 1
  • 9
  • 24
  • Possible duplicate of [Autoimplement Swift protocol methods in XCode](http://stackoverflow.com/questions/27331588/autoimplement-swift-protocol-methods-in-xcode) – JAL Apr 26 '16 at 18:39
  • @JAL I don't believe so, as I don't necessarily have missing methods like that. For example, I might have a member variable of a supertype rather than a subtype, or a method with the wrong signature (rather than not present at all), so that feature -- auto-stub -- wouldn't do what I'm hoping for. – qqq Apr 26 '16 at 18:55
  • I see, you're just looking for information, not for Xcode to auto-generate the methods – JAL Apr 26 '16 at 18:55
  • right, just so. I would expect auto-generation to be a straightforward sub-feature of this one to implement if the former exists, though. – qqq Apr 26 '16 at 18:58

1 Answers1

26

When you get that error, click on the arrow to expand it. It will show the required function(s) that are missing.

Here is an example where I implement UITableViewDataSource but I have forgot to provide the "cellForRowAtIndexPath" function.

enter image description here

Michael Peterson
  • 10,383
  • 3
  • 54
  • 51
  • 6
    The grey thingies then ask: "Do you want to add it?" but it does not seem to offer a way to actually do that. – Raphael Dec 12 '16 at 14:47