0
我想用他们的用户名从Firebase列出所有用户的列表。制作Firebase用户列表
我的问题是,我试图让所有的用户的数组。
import UIKit
import Firebase
var memberRef = Firebase(url: "\(BASE_URL)/users")
//var currentUser = DataService.dataService.USER_REF.authData.uid
var currentUsers: [String] = [String]()
class dataTableView: UITableViewController
{
override func viewDidLoad()
{
loadUsers()
}
func loadUsers()
{
// Create a listener for the delta additions to animate new items as they're added
memberRef.observeEventType(.ChildAdded, withBlock: { (snap: FDataSnapshot!) in
print(currentUsers)
// Add the new user to the local array
currentUsers.append(snap.value as! String)
// Get the index of the current row
let row = currentUsers.count - 1
// Create an NSIndexPath for the row
let indexPath = NSIndexPath(forRow: row, inSection: 0)
// Insert the row for the table with an animation
self.tableView.insertRowsAtIndexPaths([indexPath], withRowAnimation: .Top)
})
}
但是,我得到了类型NSDictionary的错误倾向转换为NSString的值。
请粘贴您的火力地堡结构为文本,而不是照片。您可以使用Firebase仪表板中的导出按钮获取该信息。文本将使我们不必在答案中重新键入结构。 – Jay