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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:16:04+00:00 2026-05-13T17:16:04+00:00

Perhaps this is the wrong way to go about this, but it seems like

  • 0

Perhaps this is the wrong way to go about this, but it seems like such a clean and workable approach that I wonder how I can make the compiler warning go away?

@interface SomeView : UIView {
 NSString *stringOfsomeImportance;
 RelatedClass *niftyService;
}
@property (nonatomic, copy) NSString * stringOfnoImportance;
@property (nonatomic, retain) RelatedClass *niftyService;

@implementation
-(void)someMethod;
-(void)otherMethods;

@implementation    RelatedClass *pvSomeObj = [[RelatedClass alloc] initWithSender:self];
[self setNiftyService:pvSomeObj];

Now, looking at the RelatedClass implementations…

@interface RelatedClass : NSObject {
  id  thesender;

@property (nonatomic, retain) id thesender;


@implementation

[thesender otherMethods];  // this generates a compiler warning
                           // that otherMethods cannot be found
                           // in SomeView, though it *is* found
                           // and seems to execute just fine

This seems like a valid approach, so I’m left wondering why the warning?
Is there a way to better “explain” this to the compiler?

Could someone kindly share if this type of linkage is encouraged or if there is a better way to link two related, interdependent classes that need to communicate with one another?

I can’t statically declare the sender object (SomeView) in RelatedClass because that seems to cause a recursion problem, as SomeView is defined with RelatedClass as a member…

Any suggestions?

  • 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-13T17:16:04+00:00Added an answer on May 13, 2026 at 5:16 pm
    1. You can define a protocol and say that your thesender object must conform to it:

      @protocol MyProtocol
         -(void)otherMethods;
      @end
      
      @interface RelatedClass : NSObject {
         id<MyProtocol>  thesender; // Now compiler knows that thesender must respond 
                                    // to otherMethods and won't generate warnings
      }
      
    2. You can send otherMethods message another way (you may need to define theSender as NSObject here):

      if ([theSender respondsToSelector:@selector(otherMethods)])
          [theSender performSelector:@selector(otherMethods)];
      
    3. Edit: Actually you can also define thesender as SomeView* in your RelatedClass using forward class declaration:

      //SomeView.h
      @class RelatedClass;
      @interface SomeView : UIView {
         RelatedClass *niftyService;
      }
      // then include RelatedClass.h in SomeView.m
      
      //RelatedView.h
      @class SomeView;
      @interface RelatedClass : NSObject {
         SomeView*  thesender;
      }
      // then include SomeView.h in RelatedClass.m
      
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Perhaps I'm going about this all wrong (and please tell me if I am),
I am only somewhat familiar with multi-threading in that I've read about it but
I just need to make a SQL table of time zones - at this
In linking a sports event to two teams, at first this seemed to make
I'm writing a test for a piece of code that has an IOException catch
[EDIT 3] I kind of "solved it" by at using the "strange" version. At
I'm working on some data access logic with Spring, my question has to do
I'm opening a new question to followup on my last one ( superview and
How do I properly draw one vector object onto a specific position of another

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.