I have been working to create a UIAlertView in Swift, but for some reason I can't get the statement right because I'm getting this error:
Could not find an overload for 'init' that accepts the supplied arguments
Here is how I have it written:
let button2Alert: UIAlertView = UIAlertView(title: "Title", message: "message",
delegate: self, cancelButtonTitle: "OK", otherButtonTitles: nil)
Then to call it I'm using:
button2Alert.show()
As of right now it is crashing and I just can't seem to get the syntax right.
Here is a funny example in Swift:
Click of View
Done with two buttons OK & Cancel
Simply do not provide otherButtonTitles in the constructor.
But I do agree with Oscar, this class is deprecated in iOS 8, so there won't be no use of UIAlertView if you're doing an iOS 8 only app. Otherwise the code above will work.
I found this one,
not good though, but it works :)
Update:
but I have found on header file as:
somebody may can explain this.
I have another trick. Suppose you have 5 classes where a logout alert to be applied. Try with swift class extension.
File- New- Swift class- Name it.
Add the following:
Implement using : self.makeLogOutAlert(). Hope it helps.