2

I have a NSData object which needs to be converted to [String:Any] and here is the code I tried:

let multiOrder = _fields["multiOrder"] as? GPBValue
if let _ = multiOrder {
  let data = NSKeyedArchiver.archivedData(withRootObject: multiOrder!)
  if let responseString = String(data: data, encoding: .utf8) {
    print(responseString)
  }
}

GPBValue object looks like NSObject<NSSecureCoding, NSCopying>

But the above code is returning nil

as diu
  • 1,010
  • 15
  • 31
  • Use: `JSONSerialization.jsonObject(with: data, options: .mutableLeaves)` – Brandon Nov 01 '18 at 01:41
  • Possible duplicate of [NSDictionary to NSData and NSData to NSDictionary in Swift](https://stackoverflow.com/questions/26376469/nsdictionary-to-nsdata-and-nsdata-to-nsdictionary-in-swift) – nayem Nov 01 '18 at 02:35

0 Answers0