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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:00:18+00:00 2026-06-12T23:00:18+00:00

I saw the example with Flower an MyGarden, but when I try to make

  • 0

I saw the example with Flower an MyGarden, but when I try to make something similar it doesn’t work. My code:

ClassA.h:

#import <Foundation/Foundation.h>

@protocol CommDelegate <NSObject>
@required
-(void)funcB;
@end

@interface ClassA : NSObject
{
    id <CommDelegate> delegate;
}
@property (retain) id delegate;
-(void)funcB;
@end

ClassA.m

#import "ClassA.h"

@implementation ClassA
-(void) start
{
    [[self delegate] funcB];
}
@end

ClassB.h

#import <Foundation/Foundation.h>
#import "ClassA.h"

@interface ClassB : NSObject <CommDelegate>
@end

ClassB.m

#import "ClassB.h"

@implementation ClassB
-(void)funcB
{
    NSLog(@"HELLO!");
}
@end

And in main I’m doing:

ClassA* classa = [[ClassA alloc] init];
[classa start];

Could someone help me, and tell what I’m doing wrong?

  • 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-06-12T23:00:19+00:00Added an answer on June 12, 2026 at 11:00 pm

    Delegation overview summary:

    1. Create a @protocol which is the methods that you wish to be callable from the delegator but are provided by your delegate.
    2. Add delegate @property in delegator’s public @interface.
    3. Use delegate property inside delegator’s implementation e.g. result = [self.delegate methodInProtocol]
    4. Set the delegate property somewhere in the delegate’s @implementation:
      delegator.delegate = self;
    5. Implement the protocol method(s) in the delegate (include <> on @interface)

    The delegate is just a pointer to an object that will implement the necessary methods for you. In your case, I think you want classA to be able to call a funcB method, but for that funcB to be implemented by someone else.

    There needs to be a delegate property in the class that wants to have another class implement these methods and then in the class that is to be the delegate, it should set the delegate property to self.

    As others have noted, you don’t set your delegate. Somewhere in classB you need a

    ClassA.delegate = self;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i saw a example for login form same blow code class Form_Login extends Zend_Form
Here's an example I saw for some GLX code: display = XOpenDisplay(0); // ...
I saw this C# using statement in a code example: using StringFormat=System.Drawing.StringFormat; What's that
I saw an example on the web but now cannot find it any more.
I saw an example that try to explain inheritance in Java. The class Employee,
I saw an example here and checked how it works but i got an
Hi I saw an example on StackOverflow which had this code: String encoding =
I recently saw an example where the following was demonstrated to work: T Add<T>(dynamic
I saw an example today of a method overriding a method in a base
I recently saw an example of Google maps in grey on a website (Can't

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.