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 4092668
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T19:31:13+00:00 2026-05-20T19:31:13+00:00

What is the difference between Delegate and Notification? I understood like delegate and protocol,

  • 0

What is the difference between Delegate and Notification?

I understood like delegate and protocol,

@protocol classADelegate

-(void)DelegateMethod;


@end



classB <classADelegate>{

   classA *ObjOfclassA=[[classA alloc]init];

    ObjOfclassA.delegate=self;

//while push later, here we have taken the pointer of classB(self) to `classA` and stored in delegate variable of classA. So, from `classA` we can call the function in `classB`

   push:classA from here.


   -(void)DelegateMethod{

        nslog(@"i am rithik from India");


     }

}


classA{

   id <classADelegate> delegate;

   -(void)viewdidload{

        [self.delegate DelegateMethod];

    }

}

My doubt is

1. Why don’t we use in classA like this

classA{

**classB** <classADelegate> delegate;


[self.delegate DelegateMethod];

}

What is the reason for using “id” and what is the difference of them?

2. we have call the method of classB’s DelegateMethod function which is came from protocol definition.

instead we can straightly call that method by defining that instance method of classB.because we have the got the pointer for classB in classA’s delegate variable.

like this.

classB{

-(void)DelegateMethod;

}

and then call this in

classA{

       classB delegate;

       -(void)viewdidload{

            [self.delegate DelegateMethod];

        }

    }

So, from the above we have avoided the protocol and id variable .

but I knew many of us use delegate and protocol. Here I came to know about any advantages while use delegate and protocol

here what is the usage of protocol implementation for method of DelegateMethod function.

instead instance definition .

What is the usage of those by @protocol. Please any one guide me right direction.

I’m new to iphone developement. Right now, I knew how to create delegate. but while I came to study about the NSNotification

That is also do the almost right job like delegate. So, when should I use the delgate or NSnotification.

  • 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-20T19:31:14+00:00Added an answer on May 20, 2026 at 7:31 pm

    Short Answer: You can think of delegates like a telephone call. You call up your buddy and specifically want to talk to them. You can say something, and they can respond. You can talk until you hang up the phone. Delegates, in much the same way, create a link between two objects, and you don’t need to know what type the delegate will be, it simply has to implement the protocol. On the other hand, NSNotifications are like a radio station. They broadcast their message to whoever is willing to listen. The radio station can’t receive feedback from it’s listeners (unless it has a telephone, or delegate). The listeners can ignore the message, or they can do something with it. NSNotifications allow you to send a message to any objects, but you won’t have a link between them to communicate back and forth. If you need this communication, you should probably implement a delegate. Otherwise, NSNotifications are simpler and easier to use, but may get you into trouble.

    Long Answer:

    Delegates are usually a more appropriate way of handling things, especially if you’re creating a framework for others to use. You gain compile time checking for required methods when you use protocols with your delegates, so you know when you compile if you’re missing any required methods. With NSNotificationCenter you have no such guarantee.

    NSNotificationCenter is kind of “hack-ish” and is frequently used novice programmers which can lead to poor architecture. A lot of times these two features are interchangeable, but more “hardcore” developers might scoff at the use of the NSNotificationCenter.


    Q: what is the reason for using “id” and what is the difference of them?

    A: Using id allows you to send any object to the method as a parameter. Note that you can not send primitives such as bools, floats, doubles, ints, etc. unless they are wrapped in their respective Object wrappers.


    classB{
    
    -(void)DelegateMethod;
    
    }
    

    and then call this in

    classA{
    
       classB delegate;
    
       -(void)viewdidload{
    
            [self.delegate DelegateMethod];
    
        }
    
    }
    

    The above example you provided would require that classA‘s delegate always be of type classB, which isn’t advantageous. Instead of using delegates in this scenario, you would probably just use a variable that referred to your other class, say, myClassB. The beauty of delegates is that you can pass around any object, and the code just works as long as they implement the required methods (which the compiler ensures, as long as it’s marked as the correct delegate type).

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

Sidebar

Related Questions

What is the difference between InvokeRequired and somecontrol.InvokeRequired ? like this, delegate void valueDelegate(string
delegate void DelegateTest(); DelegateTest delTest; Whats the difference between calling delTest.Invoke() and delTest() ?
Once it is compiled, is there a difference between: delegate { x = 0;
Is there any difference between int on_exit(void (*function)(int , void *), void *arg); and
Possible Duplicate: What is the difference between a delegate and events? Possible Duplicate: Difference
What is the difference between: [[UIApplication sharedApplication] delegate] and UIApplicationDelegate
What is the difference between early and late binding?
Is there a performance difference between i++ and ++i if the resulting value is
What is actually the difference between these two casts? SomeClass sc = (SomeClass)SomeObject; SomeClass
What is the difference between TrueType fonts and Type-1 fonts?

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.