How to look for required methods in a protocol?

74 views Asked by At

This is what I do. While looking up an apple documentation of protocol in Chrome or Xcode, I Cmd-F searching for "required". If result is zero, I conclude that all methods in that protocol are optional.

Am I doing it right? Or is there any "formal" way?

1

There are 1 answers

2
sblom On BEST ANSWER

The most authoritative answer to the "optional" vs "required" question would come directly from the header that implements the protocol in question.

If you've already got an object marked as implementing the protocol, you can right-click->Jump to Definition in XCode. Once you're at the definition, anything before the @optional keyword is required, and anything after it is optional (unless there's another @required later, but that's rare).

That said, in my experience, the Apple Developer Documentation has always been quite reliable for me in adding "required method" after any methods that the protocol does, in fact, require.