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()
})
Written by kanshuYokoo
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Swift
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#