如何解决在iPhone而非iMac模拟器上运行时,是什么导致连续不断的Firebase命中?
在iPhone的Mac模拟器上,它可以正常工作。在实际的iPhone上,即使您将该页面留在应用程序上,页面中的一个页面也会持续访问数据库。然后,这使应用程序不堪重负。如果您在控制台中查看它,则它是来自Firebase请求的连续运行数据流。其根本原因是,在iPhone上运行时会发生这种情况,而在Mac上的iPhone模拟器中运行时不会发生这种情况。 我知道很难理解零碎的代码,但是粘贴所有内容太长了。以下是导致问题的相关快照代码。是的,我知道有嵌套的快照,但是就像我在模拟器上提到的那样,它运行完美。
**let thisUsersUid = Auth.auth().currentUser?.uid //Mr. Dunn's uid
refArtists = Database.database().reference().child("people");
refArtists.observe(DataEventType.value,{snapshot in
…………
self.refArtists.observeSingleEvent(of:.value,with: {snapshot in
let myDomain = snapshot.value as? String
self.bSnap = myDomain
print("haaal",self.bSnap)
……….
thisPersonRef.observeSingleEvent(of:.value,with: {snapshot in
if snapshot.exists() {
let query = Database.database().reference().child("people").queryOrdered(byChild: "e2").queryEqual(toValue: self.bSnap)
query.observeSingleEvent(of: .value,with: { snapshot in
var allUsers = snapshot.children.allObjects as! [DataSnapshot]
///////end (1) of comment
if let index = allUsers.firstIndex(where: { $0.key == myUid } ) {
allUsers.remove(at: index) //remove the current user
} /////end (2) of comment
for userSnap in allUsers {
let name = userSnap.childSnapshot(forPath: "postID").value as? String
print(name,"NNN")
if let unwrappedName = name {
self.array1.append(unwrappedName)
print(self.array1,"uuu")
self.filteredArray = self.array1
let thisUsersUid = Auth.auth().currentUser?.uid //Mr. Dunn's uid
if snapshot.childrenCount>0{
self.people.removeAll()
for people in snapshot.children.allObjects as! [DataSnapshot] {
if people.key != thisUsersUid {
…….
return Calendar.current.isDateInToday(date1)
}
print(filteredResults,"ppp")
let countb = filteredResults.compactMap({$0}).count
print(countb,"bbb")
……..
if Calendar.current.isDateInToday(date) && countb >= 1 {
………..
self.people.append(peopl)
} else {
print ("whr")
}
} else {
print ("Alp")
}
}
print(self.array1,"los")
print(people.key,"posss")
}
self.people.sort(by: { $0.TodayLikeCount ?? 0 > $1.TodayLikeCount ?? 0 })
self.table.reloadData()
}
}
}
})
} else {
print("no")
}
})
})
}
**
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。