I have a table that is populated with the following data:
var vaccineEntry: NSMutableArray = [[
["name" : "Rabies 1-yr", "detail": "Set"],
["name" : "Rabies 3-yr", "detail": "Set"],
["name" : "Distemper", "detail": "Set"],
["name" : "Parvovirus", "detail": "Set"],
["name" : "Adenovirus", "detail": "Set"]],
[
["name" : "Parainfluenza", "detail": "Set"],
["name" : "Bordetella", "detail": "Set"],
["name" : "Lyme Disease", "detail": "Set"],
["name" : "Leptospirosis", "detail": "Set"],
["name" : "Canine Influenza", "detail": "Set"]
]]
var section = ["Core Dog Vaccines", "Non-Core Dog Vaccines"]
My tableview methods are working since whatever I put in these array of dictionary places populates my table correctly. However, my app will be updating all of the “detail” values depending on a boolean which then translates to a string. I can’t seem to find the right NSMutable Array method to perform this translation though. Here is my code for that:
if object["expired"] as! Bool == true {
let expiredTag: String = "Expired"
self.vaccineEntry.setValue("Expired", forKey: "Rabies 1-yr")
self.vaccineEntry.setValue(expiredTag, forKey: (name: "Rabies 1-yr"))
self.vaccineEntry.setValue(expiredTag, forKeyPath: "Rabies 1-yr")
self.vaccineEntry.valueForKeyPath("Rabies 1-yr")
self.vaccineEntry.setValue("Expired", forKeyPath: "Rabies 1-yr")
self.vaccineEntry.objectAtIndex(0).valueForKeyPath("name")
self.vaccineEntry.setValue("Expired", forKey: "name")
self.vaccineEntry.objectAtIndex(0).valueForKey("Rabies 1-yr")
self.vaccineEntry.replaceObjectAtIndex(0, withObject: "Expired")
let rabiesObject = ["name" : "Rabies 1-yr", "detail": "Expired"]
self.vaccineEntry.replaceObjectAtIndex(0, withObject: rabiesObject)
} else {
let updatedTag: String = "Up To Date"
self.vaccineEntry.setValue("UP to date", forKey: "name")
self.vaccineEntry.objectAtIndex(0).valueForKey("Rabies 1-yr")
}
These are all of my attempts. They all compile fine but my table data does not change from my original input at the top (“Set” is just placeholder text). I had each of these attempts commented out one by one as I was making my attempts, fyi. Any help is much appreciated!!
class Vaccine { var name = "" var detail = "" var expired = false }. That makes it so much easier to update values.