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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:13:06+00:00 2026-05-27T14:13:06+00:00

If I have a delegate which resides within its own header file myDelegate.h. Then

  • 0

If I have a delegate which resides within its own header file myDelegate.h. Then I have a class (ClassOne) that implements the delegate protocol (therefore implementing the delegate function(s)). Then I create another class (ClassTwo) that has a instance variable of myDelegate. Can I then use this variable to call the function that resides in ClassOne?

Here is the code:

//myDelegate.h
@protocol myDelegate <NSObject>

- (BOOL)myFunction:(NSString*)sString;

@end


//ClassOne.h
@interface ClassOne : NSObject <myDelegate> {

}

- (BOOL)myFunction:(NSString*)sString;

@end

//ClassOne.m
#import "ClassOne.h"
@implementation ClassOne

- (BOOL)myFunction:(NSString*)sString
{
    //do stuff
}

@end


//ClassTwo.h
#import "myDelegate.h"
@interface ClassTwo : NSObject {
    id<myDelegate> del;
}

@property (nonatomic, retain) id<myDelegate> del;

@end

//ClassTwo.m
#import "ClassTwo.h"
@implementation ClassTwo

- (void)aFunction:(NSString*)string
{
    [del myFunction:string];
}

@end
  • 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-27T14:13:07+00:00Added an answer on May 27, 2026 at 2:13 pm

    Yes, that is exactly right.

    Except myDelegate should be MyDelegate. It’s not a syntax error and will execute perfectly, but standard objective-c conventions say that you should never define a delegate with a lowercase first character.

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

Sidebar

Related Questions

I have my main application delegate which contains a method that returns an object.
Can we have same delegate for two events ? which have same number of
I can't get didAccelerate to trigger. I have the delegate implemented in my header
I'm making some tabs and I want to have my own delegate for them
I am very very new to delegates! I have an AsyncCallback delegate which runs
In my game I have a base class of Loot which has methods universal
I have a class that communicates with a server (let's call it 'Downloader'). Sometimes,
I have a delegate private delegate Color ColorDel(int x, int y); which returns a
I have object with .delegate property which i manipulate in method 'doJob'. I assign
I have two string properties setup in my cocoa application's app delegate which are

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.