Going to exchange information in ios between views

I have only a general theory question, which I was hoping to create some answers. I am learning ios and have a one-look project that I was busy with. It has a startup loop that controls a socket that connects to the server and receives chat when it arrives. Textview is updated with a new chat. Now this text is attached to the story. I am going to ask now if they will go to the story board when I add it (now I am reading this multi-page aspect) whether the viewing in the chat will continue to be updated, although the user, of course, will not see it until they return. The second question is that I can update the board panel 2 and one at the same time in the first view controller. I saw that you can pass variables to StoryBar 2 in my book in segue, but can my socket start loop,which lives in the controller’s field of view, one access type controller has two variables. If this doesn’t seem like I need to examine some kind of queue to report updates from telnet to message board 2.

+2
source share
1 answer

You start with a rather complicated project - very impressed. Here are some quick notes on storyboards and segues.

  • if you configure the storyboard using the view controller, then configure segue to a different view controller. When you create a new view controller, the original is still in memory and can respond to notifications or callbacks if you program it this way.

    • when you “pop” or “fire” your view controller, which you separated, it is gone.

    • , , prepareForSeque. .

, -:

  • , , , a. networkMethod . , , , b, - . , , , - . , , .

- b. .h

#import "ViewControllerB.h"  //this is the name of your view controller b class

a ( .h) :

@property (nonatomic, strong) ViewControllerB *viewB;

.m , segue - , - . , :

[self performSegueWithIdentifier:@"viewB" sender:self];

, :

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    self.viewB = segue.destinationViewController;  //this stores a reference for later

}

b :

-(void)networkCallbackMethod:(NSString*)stringData {

    if (self.viewB) {

     [self.viewB myCustomMethodUsingPassedData:stringData];

    }


}

, , b :

-(void)myCustomeMethodUsingPassedData:(NSString*)stringData {
     //update the view here
}

, , segue , .

, . .

+2

All Articles