ios - Why passing data between View Controllers works with segue -



ios - Why passing data between View Controllers works with segue -

why next code passing info between view controllers work ? :

-(void)prepareforsegue:(uistoryboardsegue *)segue sender:(id)sender{ if([segue.identifier isequaltostring:@"showdetailsegue"]) { viewcontrollerb *controller = (viewcontrollerb *)segue.destinationviewcontroller; controller.issomethingenabled = yes; } }

everything see creates instance of viewcontrollerb class . don't understand how instance (controller) can actual viewcontroller passing data? concept missing?

the code posted not instantiating new viewcontrollerb instance. time prepareforsegue:sender: called, view controller has been instantiated storyboard , assigned passed-in segue's destinationviewcontroller property. code is, in fact, getting reference view controller has been created , used in segue.

see section segues automatically instantiate destination view controller in view controller programming guide ios:

a segue represents triggered transition brings new view controller app’s user interface.

segues contain lot of info transition, including following:

the object caused segue triggered, known sender the source view controller starts segue the destination view controller instantiated the kind of transition should used bring destination view controller onscreen an optional identifier string identifies specific segue in storyboard

when segue triggered, ios takes next actions:

it instantiates destination view controller using attribute values provided in storyboard. it gives source view controller chance configure new controller. it performs transition configured in segue.

ios oop uiviewcontroller segue

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -