-6

What is correct place for threading either in viewWillAppear or viewDidAppear in UIViewController .

Undertaker
  • 39
  • 1
  • 7

1 Answers1

1

in general, if you want to load images that need to be seen (appear) with all other views of your view controller, then you need to load in a SYNC way (you need to wait until image is loaded before your viewController is shown) in viewWillAppear:

this way you can animate your view controller (including your image), but, of course, you may keep in mind that loading images from servers need time (and internet errors may occur), so, it may happens that a user tap to go to your viewControllers and then your app stops for a while (maybe too much, depending on the file size of your image, internet speed connection...)

So, a better approach could be:

load images in viewDidAppear in ASYNC way:

user see animation immediately to your viewController (without image) and will see your image when it will be available (with a new animation, if you will).

anyway, it depends on what you aspect your app should do, both ways could be good...

meronix
  • 6,175
  • 1
  • 23
  • 36