我有一个表单,我想用文件字段填充用户之前为他/她编辑的数据。
然而,当我试图从firebase中提取数据时,数组是空的。我觉得我编写代码的方式有关...
import UIKit
import Firebase
import Photos
class createProfileVC: UIViewController {
var userArray = [User]()
// Normal outlets
@IBOutlet weak var firstName: UITextField! // required
@IBOutlet weak var lastName: UITextField! // required - type of hunt
override func viewDidLoad() {
super.viewDidLoad()
// Get userdata from Firebase
DataService.instance.getUserdata(userId: (Auth.auth().currentUser?.uid)!) { (returnedUserArray) in
self.userArray = returnedUserArray
}
self.firstName.text = userArray[0].firstName
}
}