I have the following code that is trying to convert a dictionary to NSData:
func dataFromDict<ValueType>(dict: [String:ValueType]) -> NSData { return NSKeyedArchiver.archivedDataWithRootObject(dict) }
The compiler gives me this error to pass the dict as an argument:
Argument type '[String:ValueType]' does not conform to expected type 'AnyObject'
Edit
Decision
@vadian worked for me.
I also tried applying a dict to an NSDictionary :
return NSKeyedArchiver.archivedDataWithRootObject(dict as NSDictionary)
But getting this error:
Cannot convert value of type '[String:ValueType]' to type 'NSDictionary' in coercion
Why?
source share