0

I wanted to know how to save the data in a UITextView once the application is double tapped out/force quitted. Is there some code I can write on the textViewDidChange call that can automatically save the input? The following is my code:

    class Coordinator : NSObject,UITextViewDelegate {
    
    var parent : MultiTextField
    
    init(parent1 : MultiTextField) {
        
        parent = parent1
    }
    
    func textViewDidBeginEditing(_ textView: UITextView) {
        
        textView.textColor = .black
    }
    
    func textViewDidChange(_ textView: UITextView) {
        self.parent.obj.size = textView.contentSize.height
        
    }
    
    func textViewDidEndEditing(_ textView: UITextView) {
        print("Editing is done")
    }
    
  • Take a look at [this question](https://stackoverflow.com/questions/34744783/detect-ios-app-entering-background). The event you're reacting to is an event relating to your app, not your UITextView. – ConfusionTowers Jul 16 '20 at 17:45
  • Can you show me a coded example of how to fix this? I still can't figure it out – sid_bakshy Jul 22 '20 at 14:56

1 Answers1

0

You could save the content in userDefault in textViewDidChange ; and reload content from the userDefault when you load the view.

claude31
  • 874
  • 6
  • 8