该应用程序旨在让用户敲击表A中的单元格,然后转到表B以添加自定义类别,最后将此类别名称发送回表A并更改类别标签。协议在两个UITbaleViewControllers之间不起作用
class AddNote: UITableViewController, CatDelegate {
func selectCategory(theCatgory:String){
customCategory.text = theCatgory
}
override func viewDidLoad() {
// ....
}
}
表B:
protocol CatDelegate:NSObjectProtocol{
func selectCategory(theCatgory:String)
}
class SetCategory:UITableViewController{
var theDelegate:CatDelegate?
override func viewDidLoad() {
// test to print out the string
self.theDelegate?.selectCategory("My Category")
}
// ......
}
谁能帮助
这似乎不符合下列代码
表工作?谢谢。
你设置'theDelegate'至表A? –
为自己分配“TheDelegate”。 –