Reputation:
When I want to refresh my tableView from the Main Thread it gives me this error: Thread 1: fatal error unexpectedly found nil while unwrapping an optional value which meant that the tableView doesn't have an outlet to the ViewController. But the tableView is linked to the ViewController. What am I doing wrong?
This is the error:
This is the ViewController and outlets:
DispatchQueue.main.sync(){
print("Requestlist Finished Downloading")
if(Constants.activeViewController == 1){
self.tableViewRequestlist .reloadData()
Constants.busyRequest = false
}
else{
Constants.busyRequest = false
}
Constants.requestlistDownloaded = true
}
Upvotes: 1
Views: 84
Reputation: 14123
Use self.tableViewRequestlist.reloadData()
instead of
self.tableViewRequestlist .reloadData()
Though Xcode doesn't throw a compile time error for this but compiler will look for variable name without space.
Upvotes: 1
Reputation: 642
One possibility is that the viewcontroller gets deinitilized due to some reason before loading any views. To check that, put a breakpoint in viewDidLoad() method and another in the deinit() method.
If this is not the case then the IBoutlets must have not been linked with the viewcontroller.
Upvotes: 0