Reputation: 251
I need to set an object as key in NSMutableDictionary. I declared my dictionary as
var streamsDict : NSMutableDictionary = [:]
and adding object as
streamsDict[stream] = "Value"
but i am getting following error due to which my application crashes
Could not cast value of type 'OTStream' (0x100638590) to 'NSCopying' (0x19e0fb9e8)
I also tried
streamsDict[stream as! NSCopying] = "Value"
but again i am getting errors
`Argument type 'OTStream' does not conform to expected type 'NSCopying'`
Please suggest
Upvotes: 1
Views: 1319
Reputation: 8424
Probably you do not store your object directly in dictionary but first serialize all its properties to NSDictionary
Upvotes: 0