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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T11:24:19+00:00 2026-06-15T11:24:19+00:00

This one’s trickier to explain: I have ClassA which has MethodA , that does

  • 0

This one’s trickier to explain: I have ClassA which has MethodA, that does some stuff to some objects in ClassA, let’s say it sets a couple of labels.

ClassA has also created an instance of ClassB, which is a sidebar view. I need ClassB to perform the same stuff to objects in ClassA as MethodA, updating those labels inside that instance of ClassA.

I need ClassB to be able to call MethodA, but have it act on the specific instance of ClassA that created that instance of ClassB.

The classes (at present at least) do not inherit from one another, since they don’t actually share anything yet. I fill some data from ClassA into ClassB’s labels, and now I need to do the opposite.

I can’t call [super MethodA] from within ClassB, because they don’t inherit. What I need is something analogous to a [parent methodA], which would call that method in the class that created this ClassB object, and have it act on that specific instance of ClassA.

Does such a thing exist? Apologies, jumbled post, and I’m not sure what to search for for a vague question like this.

  • 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-15T11:24:21+00:00Added an answer on June 15, 2026 at 11:24 am

    No, if you are using composition then you need an external way to refer to the class the contains the client one.

    The easier way to do it would be to pass the parent while instantiating the object:

    @interface ClassB {
      ClassA *parent;
    }
    
    -(id)initWithA:(ClassA*)parent;
    
    @property (readonly, retain) ClassA *parent;
    
    @end
    
    
    @implementation ClassB
    
    -(id)initWithA:(ClassA*)parent {
      if ((self = [super init])) {
        self.parent = parent;
      }
    
      return self;
    }
    
    @end
    

    so that you can have in ClassB:

    -(void)method {
      [parent updateThings:params];
    }
    

    Mind that in this case, since both class declarations are cross referenced you will need a forward declaration (eg. @class ClassA) in header file to make it compile.

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

Sidebar

Related Questions

This one has me perplexed. I have a web app that does many functions,
This one has been driving me nuts. I have a div that has it's
This one's a tough one - I have a JFrame that generates JTextFields. When
This one is tough to explain inside the title. What I have going on
This one is strange... I have a server at home that's part of my
This one is driving me crazy:-) Lets say I have some test xaml code:
This one's driving me crazy... I have a loop which adds an event listener
This one's got me stumped and it's driving me nuts. I have a SiteFinity
This one has me pretty rattled so I thank you in advance for your
This one is a little tricky. Say I have this XmlDocument <Object> <Property1>1</Property1> <Property2>2</Property2>

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.