我是swift的新手,我正在研究代表和协议。在我的测试应用程序中,我正在使用此协议声明(在ViewController1中),我有这个代码:
import UIKit
//Protocol declaration
protocol viewController1Delegate
{
func didFinish(controller:ViewController1,text:String)
}
// ViewController1类
class ViewController1: UIViewController {
//delegate declaration for viewController1
var delegate:ViewController1? = nil
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
valore.text=valoreInput
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBAction func doneWithOK(sender: AnyObject) {
delegate?.didFinish(self,"done")
}
}
我的问题是XCode向我显示错误:ViewController1没有名为didFinisch的成员。我的代码有什么问题?有人可以帮我理解这个问题吗?
答案 0 :(得分:1)
delegate
应该是viewController1Delegate?
而不是ViewController1?
。