Home>
import UIKit
import Firebase
import QuartzCore
// import FirebaseAuth
// import FirebaseDatabase
class AddViewController: UIViewController {
    @IBOutlet var contentTextView: UITextView!
    var me: AppUser!
    override func viewDidLoad () {
        super.viewDidLoad ()
        contentTextView.layer.borderColor = UIColor.red.cgColor

        contentTextView.layer.borderWidth = 1.0
        contentTextView.layer.cornerRadius = 10.0
        contentTextView.layer.masksToBounds = true
    }

    @IBAction func postContent () {
        let content = contentTextView.text!
        let user = AppUser.init (data:<#T ## [String: Any] #>)
        let saveDocument = Firestore.firestore (). collection ("posts"). document ()
        _ = Auth.auth (). CurrentUser! .Uid
        saveDocument.setData ([
            "content": content,
            "postID": saveDocument.documentID,
            "senderID": user.uid,
            "createdAt": FieldValue.serverTimestamp (),
            "updatedAt": FieldValue.serverTimestamp ()
        ]) {error in
            if error == nil {
                self.dismiss (animated: true, completion: nil)
            }
        }
    }
    func setupTextView () {
        let toolBar = UIToolbar ()
        let flexibleSpaceBarButton = UIBarButtonItem (barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
        let doneButton = UIBarButtonItem (barButtonSystemItem: .done, target: self, action: #selector (dismissKeyboard))
        toolBar.items = [flexibleSpaceBarButton, doneButton]
        toolBar.sizeToFit ()
        contentTextView.inputAccessoryView = toolBar
    }
    @objc func dismissKeyboard () {
        contentTextView.resignFirstResponder ()
    }
}
  • Answer # 1

    The error is that you are not in a place where you must enter a value.
    I think<#T ## [String: Any] #>below.

    let user = AppUser.init (data:<#T ## [String: Any] #>)

    As written
    Please write [String: Any] type.