may only be called from the main thread

"may only be called from the main thread"
This common error of ios developpement .
Here is the solution.
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() 
 })

0 件のコメント:

コメントを投稿