Stephane T
Stephane T

Reputation: 85

how to define two delegates in the @interface line

In iOS,I would like to include both a delegate for the flipsideView (from a Utility Application template) and a delegate to allow to scroll the view. My attempt, which does not work, is:

@interface MainViewController : UIViewController 
<FlipsideViewControllerDelegate> <UIScrollViewDelegate> {
 }

I tried to place a comma (,) or a space between the two <>, but it does not work. Would someone be able and willing to help me concerning this question?

Thank you in advance for your help

Upvotes: 2

Views: 5104

Answers (2)

Nick Weaver
Nick Weaver

Reputation: 47241

Do it this way:

@interface MainViewController : UIViewController 
  <FlipsideViewControllerDelegate, UIScrollViewDelegate> 
{

}

The syntax is as follows:

@interface ClassName : ItsSuperclass < protocol list >

For example for multiple protocols:

@interface Formatter : NSObject < Formatting, Prettifying >

You can read more on protocols and how to adopt and conform in Apple's official Documentation.

Upvotes: 14

taskinoor
taskinoor

Reputation: 46027

Only one <> is required with comma separating the protocols.

@interface MainViewController : UIViewController 
<FlipsideViewControllerDelegate, UIScrollViewDelegate> {
 }

Upvotes: 5

Related Questions