Swift - How do I save inputed information in UITextfield via time interval? -


how save inputed information in multiple uitextfields? , when switch between viewcontrollers how inputed information stay within uitextfields when switching , forward? perhaps set within time frame resets itself?

i want uitextfields set automatically without using "load" function recall information back.

can see example in "view controller.swift" thanks.

i using xcode 7 - swift 2.

it depends how switching view controllers.

if popping, or other method destroys view controller, need store text text fields somewhere else. you've written, seems losing data.

you should make class hold data, , reference singleton on class. make class singleton so:

class somemanager {     var mysavedstring: string?     static let sharedinstance = somemanager() } 

then in view controller's viewdidload method, access information singleton class , fill views it.

self.mytextfield.text = somemanager.sharedinstance.mysavedstring 

you can make uitextfield's delegate view controller, , update saved string whenever content of uitextfield changes.

@ibaction func textfielddidchange() {     somemanager.sharedinstance.mysavedstring = self.mytextfield.text } 

Comments

Popular posts from this blog

html - Outlook 2010 Anchor (url/address/link) -

javascript - Why does running this loop 9 times take 100x longer than running it 8 times? -

Getting gateway time-out Rails app with Nginx + Puma running on Digital Ocean -