在iOS中的Firebase数据库查询中计数不匹配

时间:2018-12-05 10:53:42

标签: ios swift firebase firebase-realtime-database

这里是我编写的代码,问题是它有时会返回准确/正确的计数(连续1或2次),然后返回不匹配的计数。我想每次都获得准确的计数(从一个点到最后一个孩子的数目)

self.convoRef.queryStarting(atValue: nil, childKey: 
lastMessageId).observe(.value , with: { (snap) in

self.print(items: "Key -- > \(snap.key)")
Swift.print(String(format:"Total messages : Row - %d 
%d",indexPath.row,snap.childrenCount))

if snap.childrenCount - 1 > 0
{
 cell?.lblUnread.text = String(format:"%d",snap.childrenCount-1)
                            cell?.lblUnread.isHidden = false
}
else
{
 cell?.lblUnread.text = ""
 cell?.lblUnread.isHidden = true
}
})

0 个答案:

没有答案