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

python - RuntimeError: can't re-enter readline -

python - PyInstaller UAC not working in onefile mode -

ios - Pass NSDictionary from Javascript to Objective-c in JavascriptCore -