Search code examples
iosobjective-ciphoneswiftperformselector

What is alternative to performSelector in swift?


[[[UIApplication sharedApplication] delegate] performSelector:@selector(showMainView)];

I am using an API having the code above in a iOS swift project, and couldn't find how to write it into a proper swift code. It seems swift doesn't have function named performSelector, so what can I do to make it work in swift?


Solution

  • You should try this:

    let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
    appDelegate.showMainView()