Firebase事件侦听器失败

时间:2015-03-23 17:40:24

标签: ios swift firebase

我正在尝试将Firebase事件监听器作为我班级的一部分,但它失败了,我不知道为什么。

class User: NSObject {

let userRef = Firebase(url:"https://karmadots.firebaseio.com/karmadots/users")
let standbyRef = Firebase(url:"https://karmadots.firebaseio.com/karmadots/standby")

var firstName = ""
var lastName = ""
var userDescription = ""
var email = ""
var userID = ""
var eventHostedID = ""
var invitedToEvent:[String] = []

// Set up own user
func setupUser(){
    var id:String = self.userRef.authData.uid
    println(id)  // Prints "Simplelogin:3"

    # FAILS HERE
    self.userRef.childByAppendingPath(id).observeSingleEventOfType(.Value,withBlock: {snapshot in

       # DOESNT GET TO BREAKPOINT HERE

        println(snapshot.value)

        self.firstName = snapshot.value["firstName"] as String
        self.lastName = snapshot.value["lastName"] as String
        self.userDescription = snapshot.value["description"] as String
        self.email = snapshot.value["email"] as String
        self.eventHostedID = snapshot.value["eventHosted"] as String
        self.userID = self.userRef.authData.uid

    })
}
}

我将调用作为我的代码的一部分:

self.userRef.observeAuthEventWithBlock({ authData in
    if authData != nil {
        // user authenticated with Firebase
        println(authData)
        self.user.setupUser()
        self.performSegueWithIdentifier("Authenticate User", sender: nil)
    } else {
        // No user is logged in
    }
})

输出是:

AuthData simplelogin:3
simplelogin:3

执行firebase查询会导致失败吗?我得到一个“EXC_BREAKPOINT(代码= EXC_I386_BPT,子代码= 0x0)”,然后是一堆看起来像这样的疯狂东西:

0x10547489c:  jne    0x105474890               ;      swift_dynamicCastClassUnconditional + 48
0x10547489e:  leaq   0x36b7d(%rip), %rax       ; "Swift dynamic cast failed"
0x1054748a5:  movq   %rax, 0xb4c0c(%rip)       ; gCRAnnotations + 8
0x1054748ac:  int3   
0x1054748ad:  movq   %rdi, %rax

0 个答案:

没有答案