Store Search: main and background threads

Hi everyone!

In the StoreSearch app tutorial, on page 878 it is explained that we need to move this line of code
let url = self.iTunesURL(searchText: searchBar.text!)
to the main thread.

However, I don’t understand how can we put this code on the main thread if it is doing the time-consuming job of sending the request to the server?


Delete delete delete.

The iTunesURL(:searchText:) method does not do the searching - it simply takes the search term and returns an iTunes URL with the search term embedded in it. So that’s not the method which does the time-consuming work. We had to put that method in the main thread because it accesses a UI control (the search bar) to get the search text.

The method which does the time-consuming work at this point of the project is performStoreRequest(with:) and that is still in the background thread.


Thank you very much for the explanation!

This topic was automatically closed after 166 days. New replies are no longer allowed.