Prevent showing default data

Hi,
I'm new in Swift and whole iOS development. I'm trying to make a weather app but I have a problem. How can I prevent showing default data before loading data from API?

Here is the video default on Vimeo where you can see that when application opens it has "DEFAULT" data and after 1s or so it switches to data from API.

If I check Apple's Weather app I can see it's loading data that was before closing the app. Are they using cache?

I'm sorry if this is a dumb question

  1. label.text = "- ℃";
  2. URLCache.shared.removeAllCachedResponses() use this before request.

If I check Apple's Weather app I can see it's loading data that was
before closing the app. Are they using cache?

Yes, but only in the general sense. It’s very unlikely that they rely on URLCache itself; rather, I expect they restore the previous results from some persistence mechanism, that is, they read it from a file (-:

There’s some subtlety associated with doing this for a weather app. For example, if the data in your file is very old, or for a distant location, it’s probably best to ignore the saved data and just display a placeholder until you have something meaningful to show.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple