Method cannot be a member of an @objc protocol while using Dictionary

那年仲夏 提交于 2020-01-06 14:38:52

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!