2

I want to send data from ParcelResultViewController to ViewController(Main) but I don't have connection segue between ParcelResultViewController and viewcontroller. I shared my storyboard image and code block.

How can handle this situation ?

ParcelResultViewController.m

if (nil == self.viewcontroller) {
        UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];
        self.viewcontroller = [storyboard instantiateViewControllerWithIdentifier:@"ViewController"];
        self.viewcontroller.fieldAliases = self.gonderilenFeatureSet.fieldAliases;
        self.viewcontroller.displayFieldName = self.gonderilenFeatureSet.displayFieldName;

        NSLog(@"%@",[self.gonderilenFeatureSet.features objectAtIndex:indexPath.row]);

    }

    //the details view controller needs to know about the selected feature to get its value
    self.viewcontroller.feature = [self.gonderilenFeatureSet.features objectAtIndex:indexPath.row];

enter image description here

David Ansermot
  • 6,052
  • 8
  • 47
  • 82
fozoglu
  • 729
  • 5
  • 21
  • 1
    Since both controllers have access to that navigation controller, you can subclass it and set it's delegate to query example view controller. Then you can send messages to query example view controller through it's protocol methods. – Desdenova Mar 20 '15 at 08:33
  • 1
    `NSNotificationCenter`? Please see this [thread](http://stackoverflow.com/questions/2191594/send-and-receive-messages-through-nsnotificationcenter-in-objective-c) for more information on notification center. – Ozgur Vatansever Mar 20 '15 at 08:47
  • @ozgur thank you for comments. Is this possible to use your recommendation for my issue ? ( Teşekkürler , gönderdiğiniz class işime yarar mı ? ) – fozoglu Mar 20 '15 at 08:49
  • Definitely it is, but I would go with @Desdenova's suggestion and subclass the navigation controller which is reachable from both end, because using notification center too much makes it harder for you to keep track of what is sent to where. – Ozgur Vatansever Mar 20 '15 at 08:53
  • @Desdenova How do I do this ? I have no idea :( – fozoglu Mar 20 '15 at 09:01

1 Answers1

2

Send a notification from the parse controller with the data as object.

Use the NSNotificationCenter to do that.

David Ansermot
  • 6,052
  • 8
  • 47
  • 82
  • 1
    I will try use `NSNotificationCenter` in project Thanks – fozoglu Mar 20 '15 at 11:20
  • @DavidAnsermot I tried but it didn't work.Can you help me ? I created new simple example project this storyboard [link](http://i.stack.imgur.com/h79cO.png) and this my code [link](https://gist.github.com/fozoglu/41b52b87503e19ad536e) – fozoglu Mar 20 '15 at 13:10
  • You sure to have connected outlet ? Because your code is right excepted the part of storyboard. I would not made this like this but used appdelegate, uiwindow etc. But its not the point. The code should work. – David Ansermot Mar 20 '15 at 13:15
  • But I don't see where you add the view controller to the window – David Ansermot Mar 20 '15 at 13:15
  • My view controller is at the top of screen , I added image of simple example. My data is coming null when trying to send value via clicking button. – fozoglu Mar 20 '15 at 13:31
  • @DavidAnsermot Finally I can . I was able to pass values. Thanks. I accept the answer. – fozoglu Mar 25 '15 at 07:11