3

Suppose I make a UIViewController a UIScrollViewDelegate.

Do I need to implement all methods for the delegate, or can I just implement the 1 I care about?

Henley
  • 21,258
  • 32
  • 119
  • 207

1 Answers1

10

If you cmd + click in xcode where you have declared that you implement the protocol

<UIScrollViewDelegate>

Xcode will take you to the header file where the protocol is defined. Here you can see that all of the methods for UIScrollViewDelegate are declared as @optional therefore you can just implement the ones you want.

If you prefer the documentation then Apple marks the required methods with required method in the Tasks section.

Additionally the compiler will show warnings if you say you conform to a protocol but do not implement required methods.

Paul.s
  • 38,494
  • 5
  • 70
  • 88