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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T20:27:41+00:00 2026-05-28T20:27:41+00:00

I’m trying to connect an IBOutlet in a class (DataViewController) to another class (RootViewController)

  • 0

I’m trying to connect an IBOutlet in a class (DataViewController) to another class (RootViewController) so that I can access the instance of RootViewController in DataViewController.

There are no compile warnings or errors. When I select DataViewController in the IB scene, I can see the outlet I’ve defined in Connections Inspector->Outlets. But when I try to drag a connection from the outlet to RootViewController, it doesn’t work. It just fails without any error or indication of what’s wrong.

I’ve verified that the RootViewController scene has Custom Class “RootViewController”.

Here’s my code:

//RootViewController.h
#import <UIKit/UIKit.h>

@interface RootViewController : UIViewController <UIPageViewControllerDelegate>
@property (strong, nonatomic) UIPageViewController *pageViewController;
@end


//DataViewController.h
#import <UIKit/UIKit.h>
@class RootViewController;

@interface DataViewController : UIViewController < UIWebViewDelegate > {
    IBOutlet UIWebView *webView;
}
@property (strong, nonatomic) IBOutlet RootViewController *rvc; //this one won't connect. Why?
@property (strong, nonatomic) IBOutlet UILabel *dataLabel;
@property (strong, nonatomic) id dataObject;
@end

//DataViewController.m
#import "DataViewController.h"
#import "RootViewController.h"

@implementation DataViewController

@synthesize rvc;

//...
@end

What am I doing wrong?

  • 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-28T20:27:43+00:00Added an answer on May 28, 2026 at 8:27 pm

    You can’t do that. You need to setup a delegate protocol. See This tutorial
    and search down for the words “new delegate” and it will explain how that is done. That is the design pattern you need to use. There are several steps involved so follow closely. It is worth learning. Delegate protocols are common in iPhone Apps.

    In a current project I created a delegate protocol to communicate between two controller: SelectNoteViewController (Select) and EditNoteViewController (Edit). The basic idea is that Select is used to select from a list of notes and Edit is used to edit those notes. Now, I need Edit to have access back into the data and methods kept by Select because I have buttons in edit to call up the previous or next note from the list which is managed by Select so I implement a delegate protocol. Select is a delegate for Edit. That means Select does things for Edit. Here is the essential code.

    SelectNoteViewController.h:

    // this next statement is need to inform Select of the protocols defined in Edit
    #import "EditNoteViewController.h" // STEP 1
    
    
    @interface SelectNoteViewController : UITableViewController <EditNoteViewControllerDelegate> { ... // STEP 2: this says Select implements the protocol I created
    ...
    // STEP 3: EditNoteViewController Delegate Methods - these are the methods in the protocol
    - (Notes *)selectPreviousNote;
    - (Notes *)selectNextNote;
    

    SelectNoteViewController.m:

    // STEP 4: the protocol methods are implemented
    - (Notes *)selectPreviousNote {
        if (isPreviousToSelectedNote) {
            NSIndexPath *indexPath, *previousIndexPath;
            indexPath = [self.tableView indexPathForSelectedRow];
            previousIndexPath = [NSIndexPath indexPathForRow:indexPath.row+1 inSection:0];
            // update the selected row
            self.selectedNote = [self.fetchedResultsController objectAtIndexPath:previousIndexPath];
            [self.tableView selectRowAtIndexPath:previousIndexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
            [self setPreviousNote];
            [self setNextNote];
        } 
    return selectedNote;
    }
    
    - (Notes *)selectNextNote {
        if (isNextToSelectedNote) {
            NSIndexPath *indexPath, *nextIndexPath;
            indexPath = [self.tableView indexPathForSelectedRow];
            nextIndexPath = [NSIndexPath indexPathForRow:indexPath.row-1 inSection:0];
            // update the selected row
            self.selectedNote = [self.fetchedResultsController objectAtIndexPath:nextIndexPath];
            [self.tableView selectRowAtIndexPath:nextIndexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
            [self setPreviousNote];
            [self setNextNote];
        }
    return selectedNote;
    }
    ...
        ...
    if ([[segue identifier] isEqualToString:@"editNote"])  {
        // STEP 5: this is where Edit is told that its delegate is Select
        [[segue destinationViewController] setEditNoteViewControllerDelegate:self]; // STEP 5
    

    Select now has the structure to do be a delegate for Edit. Now Edit needs to define the protocol on its end that it is going to use to get to those methods in Select.

    EditNoteViewController.h

    #import ... // put protocol after import statements
    // STEP 6
    @protocol EditNoteViewControllerDelegate <NSObject>
    
    - (Notes *)selectPreviousNote;
    - (Notes *)selectNextNote;
    
    @end
    
    
    @interface ...
    // STEP7: Edit needs a property to tell it who the delegate is - it was set back in Select.m
    @property (weak) id <EditNoteViewControllerDelegate> editNoteViewControllerDelegate; 
    

    EditNoteViewController.m

    // STEP 8: the property is synthesized
    @synthesize editNoteViewControllerDelegate;
    
    ...
    
    // STEP 9: now when any method needs to call selectPreviousNote or selectNext Note it does it like this:
    selectedNote = [self.editNoteViewControllerDelegate selectPreviousNote];
    // or
    selectedNote = [self.editNoteViewControllerDelegate selectNextNote];
    

    That is it. Of course the protocol methods are like and other method and they can be passed parameters which what you need to do to pass data back which was your question in the first place. As a side note, see that I can pass data from Select to Edit without a protocol by creating properties in Edit and setting those properties in the prepareForSegue method of Select. Doing so gives me one shot to set some parameters when Edit is instantiated. My use of a the delegate protocol goes back to Select and has it pass another note (previous or next) to Edit. I hope that helps. You can see there are several steps to creating a delegate protocol. I numbered them 1-9. If the data is not making it back, I usually find I forgot one of the steps.

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

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace

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.