Take this simplified example:
let dict: [String: AnyObject] = ["foo": ("bar" as NSString).dataUsingEncoding(NSUTF8StringEncoding)!9]
let json = try! NSJSONSerialization.dataWithJSONObject(dict, options: [])
I cannot get that to run, it crashes with:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (NSConcreteMutableData)'
I need to send a block of JSON to my server, where some values are strings and some are NSData
. What am I doing wrong?
Aucun commentaire:
Enregistrer un commentaire