Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6012495
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:24:46+00:00 2026-05-23T02:24:46+00:00

I got this code from one of Apple’s examples: @protocol SectionHeaderViewDelegate; @interface SectionHeaderView :

  • 0

I got this code from one of Apple’s examples:

@protocol SectionHeaderViewDelegate;


@interface SectionHeaderView : UIView {
}

@property (nonatomic, retain) UILabel *titleLabel;
@property (nonatomic, retain) UIButton *disclosureButton;
@property (nonatomic, assign) NSInteger section;
@property (nonatomic, assign) id <SectionHeaderViewDelegate> delegate;

-(id)initWithFrame:(CGRect)frame title:(NSString*)title section:(NSInteger)sectionNumber delegate:(id <SectionHeaderViewDelegate>)aDelegate;
-(void)toggleOpenWithUserAction:(BOOL)userAction;

@end



/*
 Protocol to be adopted by the section header's delegate; the section header tells its delegate when the section should be opened and closed.
 */
@protocol SectionHeaderViewDelegate <NSObject>

@optional
-(void)sectionHeaderView:(SectionHeaderView*)sectionHeaderView sectionOpened:(NSInteger)section;
-(void)sectionHeaderView:(SectionHeaderView*)sectionHeaderView sectionClosed:(NSInteger)section;

@end

I’m confused on some of the notation. This is my attempt at explaining it. Please correct me if I’m wrong:

The first @protocol SectionHeaderViewDelegate; declares the start of the protocol for the SectionHeaderView class. The fourth property, id <SectionHeaderViewDelegate> delegate; is needed for classes that conform to the protocol so they can do something like instanceOfClass.delegate = self;.

Then after the /* comment */, I’m not sure why the protocol directive is used again. Is it part of the same protocol? Is it different than the protocol declared in the first half?

Is my above explanation and understanding of the code correct?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T02:24:47+00:00Added an answer on May 23, 2026 at 2:24 am

    Actually the first protocol declaration is forward declaration to solve a chicken and egg problem. Both the delegator class the delegate protocol need to know about each other so to solve this we declare @protocol SectionHeaderViewDelegate; as a forward declaration saying that it’s not defined yet but it will be there and you needn’t worry about it. This works when you do id<SectionHeaderViewDelegate> delegate in the SectionHeaderView class. The next @protocol declaration is to signal the actual start of the protocol definition.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Got this code for a viewscroller from the apple developers site. @synthesize scrollView1, scrollView2;
I've been using this method (I think I got it from one of Apple's
I got this code from the wordpress <head profile=http://gmpg.org/xfn/11> What does this means? what
I got this code from someone, it's almost perfect to create a dynamic breadcrumb,
I got this code from someone and it works very well, I just want
I got this javascript code from off the internet. It's a script that changes
I got this piece of Assembly code extracted from some piece of software, but
How can I fetch images from a server? I've got this bit of code
I got this code in order to build an url for the link using
I got this code ` // // prints out Hello World! // hello_world(); //First

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.