ios - Pass data between ViewControllers in a non-based storyboard app -


i creating ios app without storyboard, setting window's frame in appdelegate.

now, have 2 view controllers viewcontroller , settingscontroller. in settings controller have created text field(mytextfield) want store mytextfield.text in variable. how can do?

you can create 1 public property inside appdelegate file,

@property(nonatomic,strong) nsstring *passingtext; 

1. viewcontroller 2 import appdelegate:

    @interface viewcontroller2()     {      appdelegate *appdelegate;     }     @end      - (void)viewdidload     {      appdelegate = (appdelegate *)[uiapplication sharedapplication].delegate;     }     once user entered text in mytextfield, using delegate:      - (void)textfielddidendediting:(uitextfield *)textfield     {      appdelegate.passingtext = textfield.text;      } 

on second controller can read value of appdelegate.

this solve requirement.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -