IOS Swift 3 fetch onMainThread
I used this line in Objective-C
[self performSelectorOnMainThread: @selector(importComplete)
withObject: nil waitUntilDone: YES];
I've tried converting the above string to any number of options, but couldn't find anything that will compile. My current attempt is as follows:
performSelector (onMainThread: #selector(importComplete), withObject:nil, waitUntilDone: false)
I was unable to compile my changes. The above change delivers the message
"Use of an unauthorized identifier
performSelector
.
I've read everything I can find in this method and it looks like a mess in Swift 3 anyway, but I'm just learning the language and I've spent a lot of time on what should be simple syntax.
Can anyone make a suggestion here?
TIA
+3
source to share
4 answers
One of the options could be:
let selector = NSSelectorFromString("importComplete")
perform(selector, on: Thread.main, with: nil, waitUntilDone: true)
or
let selector = NSSelectorFromString("importComplete")
perform(selector, on: Thread.main, with: nil, waitUntilDone: true, modes: nil)
Depending on your needs.
+1
source to share