My TableViewCell не отображает текущие данные, которые я получаю.С помощью печати я получаю все необходимые данные, но они не отображаются в моем TbleViewCell.
Здесь я создал новый класс со всеми данными для пользователя и сообщениями:
class UserPostModel {
var post: PostModel?
var user: UserModel?
init(post: PostModel, user: UserModel) {
self.post = post
self.user = user
}
}
Объявлениемоего массива записей:
var postArray = [UserPostModel]()
Здесь я загружаю данные в новый класс:
self.observeRadius(completion: { (radius) in
let currentRadius = radius
// Üperprüfe, welche Posts im Umkreis erstellt wurden
let circleQuery = geoRef.query(at: location!, withRadius: Double(currentRadius)!)
circleQuery.observe(.keyEntered, with: { (postIds, location) in
self.observePost(withPostId: postIds, completion: { (posts) in
guard let userUid = posts.uid else { return }
self.observeUser(uid: userUid, completion: { (users) in
let postArray = UserPostModel(post: posts, user: users)
self.postArray.append(postArray)
print(postArray.post!.postText!, postArray.user!.username!)
self.postArray.sort(by: {$0.post!.secondsFrom1970! > $1.post!.secondsFrom1970!})
})
})
Здесь я загружаю данные в ячейки табличного представления:
extension DiscoveryViewController: UITableViewDataSource {
// wie viele Zellen
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
print(postArray.count)
return postArray.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "DiscoveryCollectionViewCell", for: indexPath) as! DiscoveryCollectionViewCell
cell.user = postArray[indexPath.row]
cell.post = postArray[indexPath.row]
//cell.delegate = self
return cell
}
}
Теперь я могу отображать всю информацию с распечаткой, но она не будет отображаться в моем tableViewCell.
Заранее спасибо за вашу помощь!