Last Updated: March 07, 2024
·
2.098K
· 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() 
 })