Junwoo Lee Junwoo Lee - 3 months ago 13
Swift Question

swift firebase retrieving data error

My

if
is not working

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


when I print snap's value it prints 1 but
if
is not working!!!

Answer

It can be a String type so check with dynamicType of your variable

print(snap.value!.description.dynamicType)

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