-2

I am developing an iOS application using Objective-C and I want to use a Swift class (Alert box). I implement the whole function. Without any error I can pass the values. But I am getting the following error message:

"whose view is not in the window hierarchy!"

I've tried different ways:

Method 1

presentViewController(alertController, animated: true, completion: nil)

Method 2

self.presentViewController(alertController, animated: true, completion: nil)

Method 3

var mainView:MainViewController = MainViewController()
mainView.presentViewController(alertController, animated: true, completion: nil) 

All methods are resulting the same error message.

vacawama
  • 141,339
  • 29
  • 256
  • 279
Puvanarajan
  • 2,628
  • 5
  • 24
  • 36

1 Answers1

0

In my self I found the answer for this question.

UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController,animated: true, completion: nil)
Puvanarajan
  • 2,628
  • 5
  • 24
  • 36