Reputation: 6176
could you help me understand something with the delegates and protocols :
in this code :
@protocol FirstViewControllerDelegate; @interface FirstViewController : UIVIewController { … id<FirstViewControllerDelegate> delegate; } @property (assign) id <FirstViewControllerDelegate> delegate;
Thanks for your answer
Paul
Upvotes: 0
Views: 301
Reputation: 38728
The
@protocol FirstViewControllerDelegate;
in that format is a forward declaration. It tells the compiler that FirstViewControllerDelegate
is a valid protocol that will be defined later on (sometimes just further down in the same .h file). It is required because without it the compiler will complain when it sees the line
id<FirstViewControllerDelegate>
as it has not seen its declaration.
The actual protocol may be defined something like
@protocol FirstViewControllerDelegate
{
@required
- (void)myImportantDelegateMethod;
}
Upvotes: 1