1

Previously I made my initial network calls to populate the user's feed in viewDidLoad, right after all the views were set up.

However, with iOS' state restoration mechanism, this doesn't work as the state restoration is performed after viewDidLoad, so if I want to prevent the call from being made as data is already populated from the restoration, I can't, because that's only known after viewDidLoad.

So where should I do initial network calls and the like? viewDidAppear seems wrong as every time you navigate back from the navigation controller stack that gets called. I could set a flag that the initial call has already been made, but that seems a little gross.

Typical advice seems to be to do the one time things in viewDidLoad, not viewDidAppear, which is why I'm apprehensive.

Is there a suggested strategy here?

Community
  • 1
  • 1
Doug Smith
  • 29,668
  • 57
  • 204
  • 388

1 Answers1

0

Can you set flag in the UIApplicationDelegate's delegate method,then use in the Controller's viewDidLoad?

maquanhong
  • 110
  • 2