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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:44:26+00:00 2026-05-16T23:44:26+00:00

I have a modal view which gets the user to select some data to

  • 0

I have a modal view which gets the user to select some data to add to a table. When the user presses a save button, the modal view should disappear and send the required data back to the view controller that presented the modal view for further processing. To achieve this, I have set up a protocol. The protocol method in the original view controller does not get called. My code is below, what am I doing wrong?

The header file (modal view controller):

@protocol AddTAFDataSource;

@interface AddTAFViewController : UIViewController <UIPickerViewDelegate, UIPickerViewDataSource> {
    id<AddTAFDataSource> dataSource;
    NSString *newICAOCode;
}

@property (nonatomic, assign) id<AddTAFDataSource> dataSource;

- (IBAction)saveButtonPressed;

@end

@protocol AddTAFDataSource <NSObject>
- (void)addNewTAF:(AddTAFViewController *)addTAFViewController icao:(NSString *)icaoCode;
@end

The implementation file (modal view controller):

#import "AddTAFViewController.h"
#import "TAFandMETARViewController.h"

@implementation AddTAFViewController

@synthesize dataSource;
...
- (IBAction)saveButtonPressed {
    [self.dataSource addNewTAF: self icao: newICAOCode]; 
}

@end

Presenting view controller header file:

#import "AddTAFViewController.h"

@interface TAFandMETARViewController : UITableViewController <AddTAFDataSource> {

}

@end

And finally, the presenting view controller:

#import "AddTAFViewController.h"  
        ...  
- (void)insertNewObject:(id)sender {
        AddTAFViewController *addTAFViewController = [[AddTAFViewController alloc] initWithNibName: @"AddTAF" bundle: [NSBundle mainBundle]];
        addTAFViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
        [(AddTAFViewController *)self.view setDataSource: self];
        [self presentModalViewController: addTAFViewController animated: YES];
        addTAFViewController = nil;
        [addTAFViewController release];
}

- (void)addNewTAF:(AddTAFViewController *)addTAFViewController icao:(NSString *)icaoCode {
        newICAO = icaoCode;
        [self dismissModalViewControllerAnimated: YES];
}

Just to remind, it is the above -(void)addNewTAF: method that does not get messaged. Any help/pointers in the right direction are much appreciated.

  • 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-16T23:44:26+00:00Added an answer on May 16, 2026 at 11:44 pm

    Replace:

    [(AddTAFViewController *)self.view setDataSource: self];
    

    With:

    [addTAFViewController setDataSource:self]
    

    After all, the dataSource is a property of the controller, not a controller’s view.

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

Sidebar

Related Questions

I have a property in my view model which returns a constant under some
I have a Add view which uploads file which is element of Question class
I have an application which displays modal views. In the last modal view, I
i have a user model with a password attribute, which gets saved as password_digest.
I have two classes (MVC view model) which inherits from one abstract base class.
I have a view model with a property Fields which is an ObservableCollection<FieldVM> .
In my application, we have a view model object from which we're retrieving its
I have ItemsControl which I bind to ObservableCollection On my view model I just
I have a modal view controller, and I want its navigation bar (I think
I have a Modal View Controller, and a Navigation View Controller embedded in a

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.