我正在开发一个应用程序,用户可以在其中拥有他们在该组中拥有的用户列表。用户在Firebase上表示为NSArray,因为字符串(userID)如下所示:
-members:
-0: :"intihntgnginfignrgrr"
-1: "lkoirgningitngitihnti"
-2: "jgnhngbngnbinbnbknntn"
我想检索所有"成员"该组显示其详细信息但我在解析时从Xcode 9收到以下错误。
无法转换类型的值' NSArray'预期参数类型' String.Element' (又名'字符')
以下是我尝试解析的方式:
if creator == userID {
let members = watchlist.childSnapshot(forPath: "members").value as! NSArray
self.Firebase_REference_users.observeSingleEvent(of: DataEventType.value, with: { (usersnap) in
guard let usersnap = usersnap.children.allObjects as? [DataSnapshot] else {return}
for allUsers in usersnap {
let alluserids = allUsers.key
if alluserids.contains(members) {
let name = allUsers.childSnapshot(forPath: "userName").value as! String
let users = User(profileImg: "userProfile", username: name)
wgroup.append(users)
}
}
)}
}