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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:53:19+00:00 2026-05-28T00:53:19+00:00

I am trying to pass some information between a subview and a parentview on

  • 0

I am trying to pass some information between a subview and a parentview on the navigation stack using delegates.

However for some reason when the I execute the delegate from the subview then pop the subview from the navigational controller it never enters the delegate method that is set up in the parent view.. I have tried NSLogs & Breakpoints the thread is defiantly not making it to this delegate method in the main view so I was hoping you could help me out.

First Of all I will show you how I have set up my delegate, where I call it in my subview and then where I set it up in the mainview hopefully you guys will be able to see something I have not so far.

Subview.h // I have left out things not related to the delegate

#import <UIKit/UIKit.h>

//Delegate - Protocol stuff for passing data from this view to the parent view
@protocol PassSearchData <NSObject>
@required
- (void) setManufactureSearchFields:(NSArray *)arrayValues withIndexPath:(NSIndexPath *)myIndexPath;
@end

@interface SecondViewController : UITableViewController <UITableViewDataSource> {
//Delegate (Used to pass information back to parent view)
    id <PassSearchData> delegate;
}
//Delegate (Used to pass information back to parent view)
@property (strong) id delegate;
@end

SecondView.m

#import "SecondViewController.h"
#import "FirstViewController.h"

@implementation SecondViewController

//..

//Delegate (Used to pass information back to parent view)
@synthesize delegate;

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{    
    //Access selected cells content (cell.textLabel.text)
    UITableViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];

    //Parent view logic (sends info back to the correct cell in parent view)
    if (parentViewSelectedIndexPath.section == 0) 
    {
        if (parentViewSelectedIndexPath.row == 0) 
        {
            //Predicates restrict the values that will be returned from the query
            NSPredicate *predicate = [NSPredicate predicateWithFormat:@"%K like %@",@"MANUFACTURER",cell.textLabel.text];
            filterArray = [parsedDataArrayOfDictionaries filteredArrayUsingPredicate:predicate];

            [[self delegate]setManufactureSearchFields:filterArray withIndexPath:indexPath]; 

//            NSLog(@"Filtered Array = %@", filterArray);
        }
    }
   [self.navigationController popViewControllerAnimated:YES]; //pops current view from the navigatoin stack

}//...

Then this is how I set it up inside the FirstViewController

FirstViewController.h

#import <UIKit/UIKit.h>
#import "VehicleResultViewController.h" //With this included I can now use the PassSearchData delegates of this view for passing data

@interface VehicleSearchViewController : UITableViewController <PassSearchData> {
//..

FirstViewController.m

#import "VehicleSearchViewController.h"
#import "VehicleResultViewController.h" //Subview

//..

#pragma mark - Received data from Sub view delegates

//These are the delegate method for passing data from the child to the parent view (parent being this view, with the delegate being declared in the subview)

- (void) setManufactureSearchFields:(NSArray *)arrayValues withIndexPath:(NSIndexPath *)myIndexPath
{
    manufactureSearchObjectString = [[arrayValues valueForKey:@"MANUFACTURER"] objectAtIndex:0];
    manufactureIdString = [[arrayValues valueForKey:@"MANUFACTURERID"] objectAtIndex:0]; //Restricts Models dataset
    manufactureResultIndexPath = myIndexPath;
}

If anyone knows what I’m missing/doing wrong any help would be really really heapful

any questions let me know.

Solution

In the firstviewcontroller when I go to load the secondviewcontroller inside
tableView:didSelectRowAtIndexPath: I forgot to set the secondviewcontrollers delegate before I pushed the view to the navigational stack.. so the missing code was this.

FirstView.m

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//Get the subview ready for use
        VehicleResultViewController *vehicleResultViewController = [[VehicleResultViewController alloc] initWithNibName:@"VehicleResultViewController" bundle:nil];

        //Pass the selected object to the new view controller.
        [self.navigationController pushViewController:vehicleResultViewController animated:YES];

        [vehicleResultViewController setDelegate:self];

//etc

thanks guys.

  • 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-28T00:53:19+00:00Added an answer on May 28, 2026 at 12:53 am

    Ok, first, your delegate should be a weak reference to avoid retain cycles. But I suspect maybe the delegate isn’t getting set. Can you show the code where SecondViewController is instantiated and the delegate is set? Can you set a breakpoint at the delegate call and verify that it is not nil?

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

Sidebar

Related Questions

I'm an encryption novice trying to pass some values back and forth between systems.
I've been trying to find a proper way to pass some information, such as
I'm trying to use putExtra and getExtras to pass some information in an android
I am trying to simply insert some information to a table in Oracle using
I am trying to pass some Subsonic collections to a client via a web
I'm trying to pass some files from one app to another. I communicate the
I'm trying to make a simple TCP server using Twisted ,which can do some
I am trying to create a custom object in AS3 to pass information to
I have some database information stored in config.inc.php and i'm trying to use it
I'm using Awesomium WebControl on a Form in C# and i'm trying to pass

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.