问题描述
我正在迅速编码。我已经写了一个协议
I am coding in swift. I have written a protocol
@objc protocol ServerDelegate {
optional func onDownloadDataComplete (downloadedData data : [Dictionary<String,Any>],result : ResultType,error : String)
}
首先我收到了方法不能是@objc协议的成员,因为参数2的类型无法在我的枚举的 Objective-C中表示,但我通过添加@objc对其进行了修复。现在,我收到的是字典数组。如何解决?
First I received "Method cannot be a member of an @objc protocol because the type of the parameter 2 cannot be represented in Objective-C" for my enum but I fixed it by adding @objc. Now I am receiving this for Array of Dictionary. How to fix it?
推荐答案
正如@ originaluser2所说,任何
都不能用<$ c表示$ c> @objc ,所以我创建了一个新类,添加了所需的数据成员,并使用 NSObject
继承了它,并返回了其数组而不是字典现在一切都很好。
As @originaluser2 said Any
cannot be represented in @objc
so I created a new class, added data members which I needed, inherited it with NSObject
and returned its array instead of dictionary and all is good now.
这篇关于使用字典时,方法不能为@objc协议的成员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!