我正在尝试从后面的无尽表格中加载数据,但我无法正确加载表格。它只是保持空白。我在多个地方尝试过,它们会导致崩溃。它唯一可以去的地方是在最后一次错误调用之后。然而,该表保持空白。相关代码在我的 fetchingUserDataAsync() 函数中。
这是我的表视图控制器:
import UIKit
class UserTableViewController: UITableViewController {
var backendless = Backendless.sharedInstance()
let follow:Follow = Follow()
var usernames = [""]
var userids = [""]
var userEmails = [""]
var isFollowing = [false]
func fetchingUserDataAsync() {
self.userids.removeAll(keepCapacity: true)
self.usernames.removeAll(keepCapacity: true)
self.isFollowing.removeAll(keepCapacity: true)
print("\n============ Fetching user data using the ASYNC API ============")
let query = BackendlessDataQuery()
backendless.persistenceService.of(BackendlessUser.ofClass()).find(
query,
response: { ( name : BackendlessCollection!) -> () in
let currentPage = name.getCurrentPage()
for names in currentPage as! [BackendlessUser] {
//print("User name = \(names.name)")
if(names.name != self.backendless.userService.currentUser.name){
self.usernames.append(names.name)
self.backendless.persistenceService.of(BackendlessUser.ofClass()).find(
query,
response: { ( objectId : BackendlessCollection!) -> () in
let currentPage = objectId.getCurrentPage()
for objects in currentPage as! [BackendlessUser] {
//print("User id = \(objects.objectId)")
if(objects.objectId != self.backendless.userService.currentUser.objectId){
self.userids.append(objects.objectId)
let currentUser = self.backendless.userService.currentUser
let user = objects.objectId
let whereClauseOne = "follower = '\(currentUser.objectId)' "
let whereClauseTwo = "following= '\(user)'"
//print ("I am following'\(whereClauseTwo)'")
self.backendless.persistenceService.of(objects.ofClass()).find(
query,
response: { objects -> () in
if let objects = objects{
self.isFollowing.append(true)
} else{
self.isFollowing.append(false)
}
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
}
}
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
}
}
},
error: { ( fault : Fault!) -> () in
print("Server reported an error: \(fault)")
}
)
//////////////////////////////////////////////////////////////////////////////////
self.tableView.reloadData()
}
override func viewDidLoad() {
super.viewDidLoad()
fetchingUserDataAsync()
}