您好,下面是我的plist文件的结构
请向我建议一种获取所有对象的方法,例如rnameArray,foodsArray等。我尝试使用以下扩展名,但对我不起作用
extension Dictionary {
init(plistNamed fileName: String, bundle: NSBundle = NSBundle.mainBundle()) {
guard
let pList = bundle.pathForResource(fileName, ofType: "plist"),
let dict = NSDictionary(contentsOfFile: pList)
else { self = [:]; return }
var result = [Key: Value]()
dict.forEach { key, value in
if let key = key as? Key, let value = value as? Value {
result[key] = value
}
}
self = result
}
}