You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I thought you are not supposed to access/change UI. However I've noticed in this sample, fetchJSON is executed in the background thread but is reading UI property navigationController?.tabBarItem.tag. Am I missing something?
Hi All,
I thought you are not supposed to access/change UI. However I've noticed in this sample, fetchJSON is executed in the background thread but is reading UI property navigationController?.tabBarItem.tag. Am I missing something?
@objc func fetchJSON() {
let urlString: String
if navigationController?.tabBarItem.tag == 0 {
urlString = "https://api.whitehouse.gov/v1/petitions.json?limit=100"
} else {
urlString = "https://api.whitehouse.gov/v1/petitions.json?signatureCountFloor=10000&limit=100"
}
if let url = URL(string: urlString) {
if let data = try? Data(contentsOf: url) {
parse(json: data)
return
}
}
performSelector(onMainThread: #selector(showError), with: nil, waitUntilDone: false)
}
The text was updated successfully, but these errors were encountered: