0

[[[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?

  • 1
    have you checked this link? http://stackoverflow.com/questions/24158427/alternative-to-performselector-in-swift – Miknash Jan 21 '15 at 15:06
  • 6
    Why on earth are you calling performSelector in the first place when you pass in the selector? Why not [[[UIApplication sharedApplication] delegate showMainView] ? – gnasher729 Jan 21 '15 at 15:25

1 Answers1

1

You should try this:

let appDelegate = UIApplication.sharedApplication().delegate as AppDelegate
appDelegate.showMainView()
Devran Cosmo Uenal
  • 6,055
  • 2
  • 26
  • 29