0

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

答えて

0

私がした最初のものは、型の列を与えた

let usernameRow: TextRow? = form.rowBy(tag: "username") 

let username: String? = usernameRow?.cell.textField.text 

ファイアベースでは、文字列をデータベースにプッシュするだけで済みますので、setValue関数を呼び出して変数usernameを渡すことができます

firebaseref.setValue("username": username) 
関連する問題