I'm trying to read a property list
from Data
in Swift 3 but I can't achieve that.
I'm tried something like this:
let datasourceDictionary = try! PropertyListSerialization.propertyList(from: data!, options: [PropertyListSerialization.ReadOptions], format: nil) as! Dictionary
and a I got this error:
Cannot convert value of type 'PropertyListSerialization.ReadOptions.Type' (aka 'PropertyListSerialization.MutabilityOptions.Type') to expected element type 'PropertyListSerialization.MutabilityOptions'
Then I tried something like this like I used to do on Swift 1.2:
let datasourceDictionary = try! PropertyListSerialization.propertyList(from: data!, options: [PropertyListSerialization.MutabilityOptions.immutable], format: nil) as! Dictionary
And I got this error:
'immutable' is unavailable: use [] to construct an empty option set
Then I tried this:
let datasourceDictionary = try! PropertyListSerialization.propertyList(from: data!, options: [], format: nil) as! Dictionary
and I got this error:
'[Any]' is not convertible to 'PropertyListSerialization.ReadOptions' (aka 'PropertyListSerialization.MutabilityOptions')
How can I read the property list
file from `Data in Swift 3 or what is the way to do that?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…