Swift 5 code:

func getArrayOfPlist() -> Array {
        let path = Bundle.main.path(forResource: "content", ofType: "plist")
        var contentsArray = [String]()
        if let path = path {
            if let contentsXML = FileManager.default.contents(atPath: path) {
                do {
                    let plistData = try PropertyListSerialization.propertyList(from: contentsXML, options: [], format: nil)
                    contentsArray = plistData as! Array
                } catch {
                    NSLog("Error when decoding contents from \(path)")
                }
            }
        }
        return contentsArray
    }

Example content.plist

Published by Johannes Luderschmidt

About this blog