Am new to swift and am using an array of multiple dictionaries. So i want to change the value of a particular key. Please guide me how to achieve it :
Values In Array :- [ { "Start":"2:00 AM", "End":"2:00 AM" }, { "Start":"3:00 AM", "End":"3:00 AM" } ]
To Do:- I want to change the value of key Start at index 1
Code:-
var aEntry = NSMutableArray.init()
for (index, type) in self.aEntry.enumerated(){
print("this is index value \(index)")
print("this is type value \(type)")
// Value of checkCurrentClickOfStart = 1
if index == Int(checkCurrentClickOfStart) {
let (item, newValue) = (index, "\(strHour)")
if 0 ..< self.aEntry.count ~= index {
(self.aEntry[index] as? NSMutableDictionary)?["Start"] = newValue
}
}
}
First of all Use Array instead of NSMutableArray See the example code below