initを使用して、Eurekaでファイアベースにデータを正しく保存する方法が混乱しています。私がチェックアウトしたリソースは、私の答えを明確にしていないようです。これを行う最善の方法は不明です。Eureka&InitでのFirebaseデータ
私は、構造体が含まれているUser.swift
というファイルがあります。その後、私はFormViewController
を使用してユーレカをインポートし、ファイル/ビューコントローラを持って
`struct UsersInfo {
let email: String
let password: String
let first: String
let last: String
let about: String
let age: Int
let city: String
let firebaseReference: DatabaseReference?
init(email: String, password: String, first: String, last: String, about: String, age: Int, city: String) {
self.email = email
self.password = password
self.first = first
self.last = last
self.about = about
self.age = age
self.city = city
self.firebaseReference = nil
}
init(snapshot: DataSnapshot) {
let snapshotValue = snapshot.value as! [String : AnyObject]
self.email = snapshotValue["email"] as! String
self.password = snapshotValue["password"] as! String
self.first = snapshotValue["first"] as! String
self.last = snapshotValue["last"] as! String
self.age = snapshotValue["age"] as! Int
self.city = snapshotValue["city"] as! String
self.about = snapshotValue["about"] as! String
self.firebaseReference = snapshot.ref
}
} // End Struct.
を。以下のように値が設定されている私のユーレカの行は、このファイルに格納されています。このファイル/ビューコントローラで
// Get the value of a single row
let emailrow: EmailRow? = form.rowBy(tag: "emailRowTag")
let emailvalue = emailrow?.value
// Get the value of a single row
let passwordrow: PasswordRow? = form.rowBy(tag: "passwordRowTag")
let passwordvalue = passwordrow?.value
// Get the value of a single row
let firstrow: NameRow? = form.rowBy(tag: "firstRowTag")
let firstvalue = firstrow?.value
// Get the value of a single row
let lastrow: TextRow? = form.rowBy(tag: "lastRowTag")
let lastvalue = lastrow?.value
// Get the value of a single row
let aboutrow: TextRow? = form.rowBy(tag: "aboutRowTag")
let aboutvalue = aboutrow?.value
// Get the value of a single row
let agerow: IntRow? = form.rowBy(tag: "ageRowTag")
let agevalue = agerow?.value
// Get the value of a single row
let cityrow: PushRow<String>? = form.rowBy(tag: "cityRowTag")
let cityvalue = cityrow?.value
を、私はユーレカからButtonRowを使用してカスタムボタンを持っています。私はこれを行うための関数を実装し、それをonCellSelection
と呼んだ。行の値はFirebaseと私を混乱させ、User.swift
ファイルのsnapshotValue辞書に入れてFormViewController
で実行する必要があるものです。ありがとう!タグ
はので、私は
row.tag = "username"
次に、その後、私は次のコードでそのタグを取得することができたようなものを持っていたTextRow
は