ios - How to save user's input in UITextField? -


i wanted know how can save user's input when user enters mobile phone in uitextfield?

if use text field , run app can enter data in text field when close application data gone. how can store data permanently , show again after application closed , reopened. there way save it?

at first, should save text when user did editing before user close application(e.g. saved nsuserdefaults):

self.yourtextview.delegate = self;  - (void)textviewdidchange:(uitextview *)textview {     if (textview.markedtextrange == nil)      {         nsuserdefaults *defaults = [nsuserdefaults standarduserdefaults];         [defaults setobject:textview.text forkey:@"usertext"];         [defaults synchronize];     } } 

then, load text user saved before when user open application again:

- (void)viewdidload {     [super viewdidload];      self.yourtextview.text = [[nsuserdefaults standarduserdefaults]objectforkey:@"usertext"]; } 

Comments

Popular posts from this blog

java - Jasper subreport showing only one entry from the JSON data source when embedded in the Title band -

serialization - Convert Any type in scala to Array[Byte] and back -

SonarQube Plugin for Jenkins does not find SonarQube Scanner executable -