Skip to content
Discussion options

You must be logged in to vote

Assuming the plist file is loaded into a PList object. For example:

let url = URL( ... )
let plist = PList(url: url)

With PListKit, arrays are of type PListArray which can contain any concrete type supported by the PList format (String, Int, Bool, Array, Dictionary, etc.).

This means we need to conditionally cast.

To access the Drivers array:

guard let driversArray = plist.root
    .dict(key: "UEFI")
    .array(key: "Drivers")
    .value? // get the Drivers array as PListArray
    .compactMap({ $0 as? PListDictionary }) // map array items to dictionaries
else { return }

Then you can iterate or use indexes to access the array.

Again, dictionaries are another type that can contain values of…

Replies: 3 comments 11 replies

Comment options

You must be logged in to vote
0 replies
Answer selected by orchetect
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
11 replies
@orchetect
Comment options

@webfalter
Comment options

@orchetect
Comment options

@orchetect
Comment options

@webfalter
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
bug Something isn't working question Further information is requested
2 participants