1

I have a login view page that should transition to a tab view controller once the login has been verified. However, I get an error instantiating the view within the session.dataTask

[24249:381955] [Animation] +[UIView setAnimationsEnabled:] being called from a background thread. Performing any operation from a background thread on UIView or a subclass is not supported and may result in unexpected and insidious behavior.

Which results in a

terminating with uncaught exception of type NSException

How can I validate the user and bring him to the main page after validating from a server?

Imran Q
  • 155
  • 1
  • 5

1 Answers1

4

It's because you shouldn't perform that operation on a background thread.

Move your instantiation code into main thread

DispatchQueue.main.async { 
// view instantition here.
}
Shamas S
  • 7,507
  • 10
  • 46
  • 58
  • 1
    @ImranQ Anytime you do something that alters the view, do it on the main thread. – Adrian Oct 15 '18 at 03:57
  • Do you know why that is? I was wondering what the key differences are between background threads and main threads – Imran Q Oct 15 '18 at 15:26