imzyf / ios-swift-learning-notes

📝 iOS Swift Learning Notes - see Issues
MIT License
0 stars 0 forks source link

GCD demo #72

Open imzyf opened 6 years ago

imzyf commented 6 years ago
            let queue = DispatchQueue.global()
            queue.async {
                if let data = self.performStoreRequest(with: url) {
                    self.searchResults = self.parse(data: data)
                    self.searchResults.sort(by: <)

                    DispatchQueue.main.async {
                        self.isLoading = false
                        self.tableView.reloadData()
                    }
                    return
                }
            }
imzyf commented 6 years ago
let url = iTunesURL(searchText: searchBar.text!)
print("URL: '\(url)'")

if let data = performStoreRequest(with: url) {                 
    searchResults = parse(data: data)
    searchResults.sort(by: <)
}

isLoading = false
tableView.reloadData()