Last Updated: May 07, 2024
·
2.231K
· kanshuYokoo

ios "may only be called from the main thread"

"may only be called from the main thread"
When you come up with the error, it is mainly because the function dealing with UI was called not from main thread.
It must be called from the main thread as follow

DispatchQueue.main.async(execute: {
  // call any function ex. doSomething()
   self.doSomething() 
 })