I am writing an application in Swift, and as a result, you need to write a class that is subclassed UIViewControllerand conforms to several protocols (including UIAlertViewDelegate, UITableViewDelegateand UITableViewDataSource). I am currently using beta version of Xcode 6 and am encountering great difficulties.
The problem I ran into comes from a class declaration:
class TableAddition : UIViewController, UIAlertViewDelegate {
It seems that the compiler does not recognize the protocol, and when I try to implement the following method:
@optional func alertView(alertView: UIAlertView!, clickedButtonAtIndex buttonIndex: Int) {
}
I get the error message "attribute" optional "can only apply to protocol members." Although deleting @optionalcancels the error, I do not believe that this method is recognized as a member of the protocol UIAlertViewDelegate(Xcode never autocompleted the implementation of the method for me).
Is this a problem on the Swift side of things, or is it a mistake on my part?
source
share