当我从下面的firebase数据库运行快照时,它将返回
任择(498895446)
当我只希望它回来的时候
498895446
作为一个整体。我已经尝试过toint(),但是它没有工作,因为我得到了一个错误。我怎么才能摆脱这个可选的。
let ref = FIRDatabase.database().reference().child("Users + infomation").child(currentuser).child("timeStamp ")
ref.observeSingleEventOfType(.Value, withBlock : {(snapShot) in
let val = snapShot.value
if snapShot.exists(){
print("\(val)")
}
else if snapShot.exists() == false {
print("snappyaintexist")
}
})发布于 2016-10-23 06:40:53
试着:-
let ref = FIRDatabase.database().reference().child("Users + infomation").child(currentuser).child("timeStamp ")
ref.observeSingleEventOfType(.Value, withBlock : {(snapShot) in
if let val = snapShot.value as? Int{
print("\(val!)")
}else{
print("snappyaintexist")
}
})https://stackoverflow.com/questions/40200154
复制相似问题