我正在尝试使用swift将字典对象传递给Objective C协议.
协议代码段如下:
@protocol MessageDelegate
- (void)handleNewMessageArrived:(NSDictionary *)messageContent;
@end
Run Code Online (Sandbox Code Playgroud)
这是实现协议的快速类:
class ViewController: UIViewController, MessageDelegate
{
...
func handleNewMessageArrived(messageContent : NSDictionary!)
{
...
}
}
Run Code Online (Sandbox Code Playgroud)
但是构建失败了,我得到的错误是:
" 类型'ViewController'不符合协议'MessageDelegate "
我查看了这个SO问题,但它处理了一个特定的对象类型.
我声明\实现委托方法的方式有错误吗?或者我假设参数是在swift中映射的方式?
我是Swift的新手,所以任何帮助都会非常感激.