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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:35:19+00:00 2026-06-12T01:35:19+00:00

Im trying to send some info from a modal view to a delgate. But

  • 0

Im trying to send some info from a modal view to a delgate. But it seems like my delegate doesnt follow through, it gets null. It looks like this in IB https://i.stack.imgur.com/4vIVT.png.
But it works if i remove the navigationController that is right before the modal view and use the buttons in the View.
please help, ive tried for like 5 hours… :/

Heres the modalViewController code:
#import
#import “Link.h”

@protocol modalViewDelegate <NSObject>

-(void)closeview;
-(void)saveLink:(Link *)link;

@end

@interface modelViewController : UIViewController
@property (weak, nonatomic) IBOutlet UITextField *titel;
@property (weak, nonatomic) IBOutlet UITextField *url;

@property (nonatomic, weak) id <modalViewDelegate> delegate;

- (IBAction)exitModal:(id)sender;
- (IBAction)saveLink:(id)sender;

@end

and .m:

#import "modelViewController.h"

@interface modelViewController ()

@end

@implementation modelViewController
@synthesize titel;
@synthesize url, delegate;

- (IBAction)exitModal:(id)sender {
    //[self.delegate closeview];
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction)saveLink:(id)sender {
    if (titel.text.length > 0 && url.text.length > 0) {

        NSString *urlen = [NSString stringWithFormat:@"%@", url.text];

        Link *linken = [[Link alloc] initWithURL:[NSURL URLWithString:urlen]];
        linken.title = titel.text;

        NSLog(@"%@", delegate); **//returns null when pressing button** it returns null if i put it in viewDidLoad to..

        [self.delegate saveLink:linken];

        [self dismissModalViewControllerAnimated:YES];



    } else {
        UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:nil message:@"warning" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
        [alertView show];
    }
}
@end

the MasterViewController .h (that pushes the modalview:

#import <UIKit/UIKit.h>
#import "modelViewController.h"

@class DetailViewController;

@interface MasterViewController : UITableViewController <modalViewDelegate>
....

and .m

#import "MasterViewController.h"
#import "DetailViewController.h"

@implementation MasterViewController

@synthesize detailViewController = _detailViewController;
@synthesize links;

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.identifier isEqualToString:@"linkPush"]) {
        // Skicka länken till detaljvyn
        DetailViewController *detailVC = segue.destinationViewController;
        detailVC.link = [self.links objectAtIndex:self.tableView.indexPathForSelectedRow.row];
        NSLog(@"%@", detailVC);
    }

    //this is the modalview "pusher"
    if ([segue.identifier isEqualToString:@"newLink"]) {

        modelViewController *mvc = segue.destinationViewController;
        mvc.delegate = self;
        NSLog(@"%@", mvc.delegate);
    }


}

- (void)closeview {
    [self dismissModalViewControllerAnimated:YES];
    //[self.tabBarController dismissModalViewControllerAnimated:YES];
}

-(void)saveLink:(Link *)link{

    NSLog(@"hello");
    [links insertObject:link atIndex:links.count]; //updates a Tableview and works fine if delegate is called

    [self.tableView reloadData];
    //[self dismissModalViewControllerAnimated:YES];
}
  • 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-12T01:35:20+00:00Added an answer on June 12, 2026 at 1:35 am

    If your destination view controller is wrapped into a navigation controller, you have to refer to it differently in prepareForSegue:

    UINavigationController *nav = segue.destinationViewController;
    DetailViewController *dvc = [nav.viewControllers objectAtIndex:0];
    

    Now setting the properties, including the delegate, should work.

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

Sidebar

Related Questions

I'm trying to send some data from the server to the client, but the
I'm trying to send some information to our CRM from a form on our
I am trying to send some text in an email from my cocoa app
I am currently trying to send some data from and Android application to a
I'm trying to send a URL with some parameters using HttpPost but it has
So I'm trying to scrap some car info off of Gasbuddy.com, but I'm having
I am trying to send info using USLStream from flash client to JAVA server.
I'm trying to parse socket info from /proc/net/tcp and while I can identify some
I am trying to access some basic info from an XML based API. I'm
I'm trying to scrape some information from a web site, but am having trouble

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.