至此: 这是我在Firebase上的数据库
我有一个代码,当我使用唯一的电子邮件登录时,它会给我来自数据库的firstName
和lastname
。这是代码:
func retrieveInfo () {
let reference = Database.database().reference().child("User_Informations").queryOrdered(byChild: "email")
reference.queryEqual(toValue: emailTextfield.text!).observeSingleEvent(of: .childAdded) { (snapshot) in
let dictionary = snapshot.value as! [String : String]
let firstName = dictionary["firstName"]
let lastName = dictionary["lastName"]
}
}
此retriveInfo
可以成功检索名字和姓氏,但是问题是我想将名字和姓氏传递给另一个视图控制器,以便在包含(名字和姓氏)的文本字段上显示它”看到图片”:
这是目标视图控制器的代码:
class HomeScreenViewController: UIViewController {
@IBOutlet var firstNameLabel: UILabel!
@IBOutlet var lastNameLabel: UILabel!
@IBOutlet var diverRankLabel: UILabel!
@IBOutlet var personalImage: UIImageView!
var firstNameChanged = Information().firstName
var lastNameChanged = Information().lastName
var diverRankChanged = ""
let databaseref = Database.database().reference()
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
information
类:
class Information {
//Objects
var firstName : String = ""
var lastName : String = ""
var email : String = ""
var diverRank : String = ""
}
希望一切都清楚,在此先感谢:)