我正在开发一个与 Parse 相关联的应用程序,因此我使用的是PFQueryTableViewController
.
我只是想知道在运行应用程序时如何检查互联网连接。
目前,如果我关闭互联网连接然后运行应用程序,我会得到表格的加载微调器,但显然,什么都没有加载。最终,微调器停止了,我只剩下一张空白桌子。
我已经阅读了有关 using的内容Reachability
,但不确定如何将其放入我当前的应用程序中。
本质上,我想要的是,每次用户启动应用程序时,它都会检查互联网连接,如果有,那就太好了!如果没有,它会显示一个提示说没有连接。
有人可以帮忙吗?我已经为queryForTable()
我认为应该进行此检查的函数添加了代码。如果您需要查看我的任何其他代码,请告诉我。谢谢
override func queryForTable() -> PFQuery {
let query = PFQuery(className: "Reviews")
if indexArray == 0 {
query.orderByDescending("createdAt")
} else if indexArray == 1 {
query.orderByAscending("FilmName")
} else if indexArray == 2 {
query.orderByDescending("OurRating")
} else if indexArray == 3 {
query.orderByAscending("OurRating")
} else if indexArray == 4 {
query.orderByDescending("WantToSeeThisCount")
} else if indexArray == 5 {
query.orderByAscending("DirectedBy")
} else if indexArray == 6 {
query.orderByDescending("UpVoteCount")
} else if indexArray == 7 {
query.orderByDescending("DownVoteCount")
}
query.whereKey("ToDisplayInApp", equalTo:true)
// Add a where clause if there is a search criteria
if filmSearchBar.text != "" {
query.whereKey("FilmName", containsString: filmSearchBar.text!)
}
return query
}