0
votes

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
downloadedData data : [NSDictionary] - Luca Davanzo
Any cannot be represented in obj-c. What are you using your dictionary for? I highly doubt you're not able to be any more type specific than Any. - Hamish
My dictionary contains values of different types such as string, int, nsdata, UIImage. - kashif789us
What is your use case? It sounds like you have an XY Problem. - JAL
@kashif789us Why do you need object and value types? Just make it AnyObject and use NSNumber or NSValue for any values? - JAL

1 Answers

0
votes

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.