我想运行下面的代码,但无法转换rest.value而没有前面的“可选”。以下是代码试图解决这个问题时,我得到:无法将anyObject转换为字符串
//for Withdrawl children
transRef.child("Withdraw").observeSingleEventOfType(.Value, withBlock: { (snapshot) in
//creates enumerator of the snapshot children for
let enumerator = snapshot.children
while let rest = enumerator.nextObject() as? FIRDataSnapshot {
let curString = (rest.value) as! String
self.anArray.append(curString)
//printing the rest.value to make sure there are children to iterate through
print(rest.value)
}
self.tableView.reloadData() //<<<<<<<<<<<< RELOAD TABLEVIEW
})
这是我收到的错误:Could not cast value of type '__NSCFNumber' (0x10d068368) to 'NSString'
可能的复制[iOS Swift:无法将值类型'\ _ \ _ NSCFNumber'转换为'NSString'](http://stackoverflow.com/questions/40798220/ios-swift-could-not-cast-value-type-nscfnumber-到的NSString) – Sasang