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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T17:09:22+00:00 2026-05-22T17:09:22+00:00

So this is the code i have: ViewA.h: #import ViewB.h #import ViewC.h @interface ViewA

  • 0

So this is the code i have:

ViewA.h:

#import "ViewB.h"
#import "ViewC.h"

@interface ViewA : UIViewController {

    ViewB *viewB;
    ViewC *viewC;

}

@property(nonatomic,retain) ViewB *viewB;

@end

ViewA.m:

@synthesize viewB;

-(void)viewDidLoad {
viewB = [[ViewB alloc] initWithFrame:CGRectMake(0, 0, 320, 328)];
    [self.view addSubview:viewB];

   viewC = [[ViewC alloc] initWithFrame:CGRectMake(0, 332, 320, 84)];
    [self.view addSubview:viewC];

    }

ViewB.h:

-(void)methodToPass;

ViewB.m:

-(void)methodToPass {

NSLog(@"Passed.");
}

ViewC.h:

#import "ViewB.h"

@interface ViewC : UIScrollView {

ViewB *viewB;

}

-(void)methodWhichDoesGetPassed;

ViewC.m:

#import "ViewA.h"

@implementation ViewC

ViewA *viewA;

-(void)methodWhichDoesGetPassed {
NSLog(@"Test here");
[viewA.viewB methodToPass];

}

So the key bit of that is that i tried to pass the method to viewB, from viewC, through viewA in that last part. When i run the app, i get the “Test here” but not the “Passed”, so it doesn’t pass this through.

Any ideas how to fix 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-05-22T17:09:23+00:00Added an answer on May 22, 2026 at 5:09 pm

    Since viewC is a subview of viewA, you should send messages to the superview.

    change it to

    ViewA *view = (ViewA *)self.superview;
    
    [view.viewB methodToPass];
    

    EDIT

    You can even check if the superview is an instance of ViewA before casting.

    if ( [self.superview isMemberOfClass:[ViewA class]] ) {
        ViewA *view = (ViewA *)self.superview;
        [view.viewB methodToPass];
    }
    

    EDIT2

    Rather than having to message up to viewA and down to viewB again, wouldn’t it be better to pass viewB to viewC on instantiation. Suggesting some changes based on that.

    ViewA.m:

    @synthesize viewB;
    
    -(void)viewDidLoad {
        viewB = [[ViewB alloc] initWithFrame:CGRectMake(0, 0, 320, 328)];
        [self.view addSubview:viewB];
    
        viewC = [[ViewC alloc] initWithFrame:CGRectMake(0, 332, 320, 84)];
        viewC.viewB = viewB;
        [self.view addSubview:viewC];
    
    }
    

    ViewC.h:

    #import "ViewB.h"
    
    @interface ViewC : UIScrollView {
        ViewB *viewB;
    }
    @property (nonatomic, retain) ViewB *viewB;
    
    -(void)methodWhichDoesGetPassed;
    ...
    @end
    

    ViewC.m:

    @implementation ViewC
    
    @synthesize viewB;
    
    -(void)methodWhichDoesGetPassed {
        NSLog(@"Test here");
        [viewB methodToPass];
    
    }
    

    Original Answer

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

Sidebar

Related Questions

I have this code: hubSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { public void onItemSelected(AdapterView<?> parentView, View selectedItemView, int
I have this code: tableList = [[NSMutableArray alloc] initWithObjects:@First View,@Second View,nil]; I have synthesized
Say I have this line of code in the view. <?php echo CHtml::activeTextField($model,'start_time'); ?>
In my views.py, i have a snippit of code like this: def clean_post_data(form): for
I wrote this code I have these errors Cannot implicitly convert type x.Program.TreeNode' to
So I have this code for these Constructors of the Weapon class: Weapon(const WeaponsDB
Suppose I have this code: var myArray = new Object(); myArray["firstname"] = "Bob"; myArray["lastname"]
So I have this code that takes care of command acknowledgment from remote computers,
So I have this code in a google app engine template: <select name='voter'> {%
Hey I have this code right here: http://pastie.org/534470 And on line 109 I get

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.