I have created a PLIST in the following format:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>radiodata</key>
<array>
<dict>
<key>make</key>
<string>Zenith</string>
<key>model</key>
<string>X334</string>
<key>sn</key>
<string>12345</string>
</dict>
<dict>
<key>make</key>
<string>RCA</string>
<key>model</key>
<string>XRS</string>
<key>sn</key>
<string>54321</string>
</dict>
<dict>
<key>make</key>
<string>Trav-Ler</string>
<key>model</key>
<string>H1X</string>
<key>sn</key>
<string>5554</string>
</dict>
</array>
</dict>
</plist>The PLIST, named RadioData.plist, resides in the Documents folder of my app.
I am able to display the data in a TableView from RadioData.plist without issue.
I have attempted to use the following code to remove a dictionsary from the plist array. It does not work.
I am seeking assistance in determining the error in my code.
I tried to use the following forKey format because each dictonary is labeled "Item 0", "Item 1"....ect
forKey: "Item " + String(indexPath.row)override func tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath) {
if editingStyle == .delete {
radios.remove(at: indexPath.row)
tableView.deleteRows(at: [indexPath], with: .fade)
/
let urls = FileManager.default.urls(
for: .documentDirectory, in: .userDomainMask)
let path = urls.first!.appendingPathComponent("RadioList.plist").path
radioInfo?.removeObject(forKey: "Item " + String(indexPath.row))
radioInfo?.write(toFile: path, atomically:true)
} else if editingStyle == .insert {
/
}