Home>
In trouble

If i paste an image from the photo library to textView, the image will be overwritten

Applicable code
import UIKit
class testViewController: UIViewController, UIImagePickerControllerDelegate, UITextFieldDelegate, UINavigationControllerDelegate {

    @IBOutlet weak var shousaiTextView: UITextView!
    override func viewDidLoad () {
        super.viewDidLoad ()
    }
    // MARK: -Button to paste image
    var picker: UIImagePickerController! = UIImagePickerController ()
    @IBAction func gazou (_ sender: Any) {
        // Select image from Photo Library
        picker.sourceType = UIImagePickerController.SourceType.photoLibrary
        // set the delegate
        picker.delegate = self
        // Set the text color of the picker NavigationBar that appears
        picker.navigationBar.tintColor = UIColor.white
        // Set the background color of the picker NavigationBar that appears
        picker.navigationBar.barTintColor = UIColor.gray
        // show picker
        present (picker, animated: true, completion: nil)
    }
    // MARK: -Process to paste image to memo
    func imagePickerController (_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey: Any]) {
        if let image = info [.originalImage] as? UIImage {
            let fullString = NSMutableAttributedString (string: shousaiTextView.text)
            let imageWidth = image.size.width
            // If I want to adjust the width of the image, subtract padding etc. from frame
            let padding: CGFloat = 16
            let scaleFactor = imageWidth/(shousaiTextView.frame.size.width-padding)
            let imageAttachment = NSTextAttachment ()
            imageAttachment.image = UIImage (cgImage: image.cgImage !, scale: scaleFactor, orientation: .up)
            let imageString = NSAttributedString (attachment: imageAttachment)
            fullString.append (imageString)
            // Set the text including the image in TextView
            shousaiTextView.attributedText = fullString
        }
        dismiss (animated: true, completion: nil)
    }
}
What I tried

https://www.tutorialfor.com/go.php?id=213275
From the above hp, I thought that I would tag each photo one by one, but I had no idea how to do it.

I would be happy if you could give me just a hint. Thanking you in advance.