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 ()
}
}
Related questions
- swift : I can install Realm with carthage but I can't compile it
- ios - i want to display the initial text value of uitextfield in swiftui
- xcode - how to randomly extract from an array and combine them into another array
- ios - i want to limit the number of characters for multiple uitextviews
- why can't i pass values by value in swift (xcode)
- xcode - i want to change the start position of the gradation
- about xcode code
- i cannot turn on "push notifications" in xcode
- xcode - i want to enter textfield when tapping swiftui button
- xcode - i want to get the value of dictionary type
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.