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

  • Home
  • SEARCH
  • 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 6383867
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:42:12+00:00 2026-05-25T02:42:12+00:00

I have just been learning iPhone apps development but I have a hard time

  • 0

I have just been learning iPhone apps development but I have a hard time in understanding what delegate actually means? Can anyone tell me with example what it does and how important it is? Thanks for any helps!

  • 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-25T02:42:12+00:00Added an answer on May 25, 2026 at 2:42 am

    It’s a key concept to understand conceptually so getting your head around how to think about it ahead of the technical details is important. Simply put, a delegate is a callback.

    Two main scenarios to use delegates:

    1. A class or control wants to abstract out the details on how to do work (like retrieve data).
    2. Allow others to hook code into a pipeline.

    Examples:
    UITableView – a table view is just a control that knows how to render a list of cells. It handles all the heavy lifting of rendering, scrolling, etc… But, it has no idea how to load your data. So you implement a datasource delegate which has methods to get the cell data for a given row etc… That makes it easy on you. You just use the control and plug in the specifics for your data. The UITableView will do everything for you … just answer a few specific questions for. A delegate answers those few specific questions.

    A text control – you add a text control to your view and voila! you can type in it and alls good. But what if you want to do something when they start typing or when they’re done typing? Well, the text control offers a delegate with methods that allow you to hook into the execution pipeline of the text control. It allows the text control to do everything for you and allows you to interject code where you need it. Many times, there’s way to interject code to make a decision on whether something is allowed. The control will call back and ask, should I be able to do x? You can interject code and influence the behavior.

    If you’re creating a control or class, you can create your own protocol, datasource delegates etc… so your control can focus on doing what’s advertised. For example, let’s say you wanted to create a task control. You could:

    First, create a contract. Hey, if you’re going to provide data for my control, these are the questions I’m going to ask you. I’ll take it from there… In this case, I’m going to ask you the number of tasks and I’m going to have you give me a task given the row number.

    @protocol XXTaskBoardDelegate <NSObject>
    -(NSInteger*)getTaskCount;
    -(XXTask*)getTaskForRow:(NSInteger*)rowNumber;
    @end
    

    In the control or class, give the consumer a way to give us the delegate datasource class that will answer the questions the control will ask. At this point, the control is a pure control. It knows nothing about how you get your data. It’s asking for an object (id) that implements a contract/protocol. id

    @implementation XXTaskBoard
    - (void)setDelegate:(id<XXTaskBoardDelegate>)newDelegate
    {
        // the control stores the delegate so it can callback and ask you questions.
    }
    

    Then, for the delegate class, in the header declare you implement that formal protocol
    and in the implementation m file you provide the code.

    @interface AppController : NSObject<XXTaskBoardDelegate> 
    {
        //...
    }
    

    then, implement it in the implementation

    @implementation AppController
    - (NSInteger*)getTaskCount
    {
        return [model queryTaskCount];
    }
    
    - (XXTask*)getTaskForRow:(NSInteger*)rowNumber
    {
        return [[model tasks] getItem:(NSInteger*)rowNumber];
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Its a newbie question, and I have just been learning WCF. Can we change
I have just been learning about how styles and control templates in WPF can
I have just started learning NHibernate. Over the past few months I have been
I'm currently using the hilo id generator for my classes but have just been
I have been just learning redis and node.js There are two questions I have
I've just been learning about master pages in ASP.NET 2.0. They sound great, but
I have been learning (slowly but surely) how to do deal with sqlite databases
I've just been learning lambda (About time) and I've figured some things out, I
I have been learning C++ for three months now and in that time created
I have just started learning coding and PHP so I have been looking at

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.