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
Post a Comment