问题
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)
}
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?
回答1:
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.
来源:https://stackoverflow.com/questions/37054049/method-cannot-be-a-member-of-an-objc-protocol-while-using-dictionary