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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T02:47:15+00:00 2026-05-28T02:47:15+00:00

In the apps I worked on, I often found such lines of code [delegate

  • 0

In the apps I worked on, I often found such lines of code

[delegate aFunction];

that generated the “instance method “aFunction” not found (return type defaults to id)” warning

Now, I did a bit of research on SO and found out that the warning can be removed by declaring the function for cases when you call it on self ([self aFunction];), but none of the answers said anything about my case, when I use a delegate.

So, long story short, what can I do to correctly call a delegate’s method inside another class?
Things appear to work fine, so this is not a major issue, but a warning means I’m not doing something completely correct so I would like to learn what’s the best practice for such cases

Thank you for your help in advance!

  • 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-28T02:47:15+00:00Added an answer on May 28, 2026 at 2:47 am

    So, if I’m understanding you correctly, your issues can be taken away by declaring your protocol as follows:

    @class SomeClass;
    @protocol SomeClassDelegate <NSObject>
    @required
    - (void)thisObjectDidSomething:(SomeClass*)instance;
    @optional
    - (void)thisObjectDidSomethingUnimportant:(SomeClass*)instance;
    @end
    

    Then your delegate ivar and property look like this (use assign instead of weak if you’re not using ARC):

    @interface SomeClass () {
        __weak id<SomeClassDelegate> delegate_;
    }
    @property (weak) id<SomeClassDelegate> delegate;
    

    And in the .h file of any class that’s going to implement that protocol, do this:

    @interface TCReader : NSObject <SomeClassDelegate> {
    
    }
    

    Since it’s safe to call selectors on nil, for required methods, you can just:

    [self.delegate thisObjectDidSomething:self]
    

    But for optional methods, you’d better:

    if ([self.delegate respondsToSelector:@selector(thisObjectDidSomethingUnimportant:)]) {
        [self.delegate thisObjectDidSomethingUnimportant:self]
    }
    

    The main point here is that by declaring and making use of a protocol, you let XCode know that those methods are defined for objects implementing the protocol. If you require that your delegate implement that protocol, then Xcode knows that your delegate has those methods defined.

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

Sidebar

Related Questions

I had a bunch of apps that worked great in iOS 4. None of
when i deploy my apps that worked fine using the django test server I
I've noticed that the majority of enterprise web apps I've worked on over the
Greetings, I've worked on quite a few apps now that are using the MVC
I worked with iPhone Xcode Traget to create multiple iPhone apps with single code
I tried to create multiple iPhone apps using same XCode project and that worked
My apps are installed. They used to work. Now that I made some edits
I have some .net apps running that I need to monitor for example, then
Do any apps/packages exist that will support writing to OS X's log database from
I've worked with JqueryMobile to build HTML5 mobile apps. I use a cache manifest

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.