swift firebase检索数据错误

时间:2016-08-08 08:57:56

标签: swift firebase firebase-realtime-database

我的if无效

    feelingRef.child("conditions/needsattention").observeEventType(.Value) { (snap: FIRDataSnapshot) in
            print((snap.value?.description)!)
            if (snap.value?.description)! == 1 {
                self.conditionLabel.text = "관심필요"
            }
        }

当我打印snap的值时,它会打印1,但if无法正常工作!!!

1 个答案:

答案 0 :(得分:0)

它可以是String类型,因此请查看变量的dynamicType

print(snap.value!.description.dynamicType)

if (snap.value!.description)! == "1" {
                self.conditionLabel.text = "관심필요"
}