Pergunta

I have a simple app which connects to a web server and the web server returns a JSON value.

I am trying to send the JSON value from ViewController1 to "linkController", however when I send the sender over to ViewController2 the sender value is null?

Here is my code:

    -(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([segue.identifier isEqualToString:@"linkControllerSegue"]) {
        linkController *lc = [segue destinationViewController];
        lc.introString =  sender;

    }
}

This is part of my linkController.h file:

    @interface linkController : UIViewController
{
    // succes view outlets
    IBOutlet UILabel *short_url;
    IBOutlet UILabel *full_url;
    UIDataDetectorTypes *json;


}

@property (weak, nonatomic) NSDictionary *introString;

And my linkController.m file:

@synthesize introString;

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    NSLog(@"%@", introString);
}

The segue is being called through the code:

[self performSegueWithIdentifier:@"linkControllerSegue" sender:nil];

The NSLog in the viewDidLoad method returns: (null).

Is there anything I am doing wrong?

Many Thanks,

Peter

Foi útil?

Solução

Try:

 lc.introString =  short_url.text;

instead of:

 lc.introString =  sender;
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top