I have an array of string which to convert to an array of images.
var inviteStatus = [Any]()
inviteStatus = ["accepted", "accepted", "pending", "pending"]
When the invite status is "accepted", I want it to be replaced with an image at that index. The desired result is this:
inviteStatus = [UIImage(named: "accepted.png"), UIImage(named: "accepted.png"), UIImage(named: "pending.png"),, UIImage(named: "pending.png")]
I tried with this following code but it's not working:
for (index, str) in self.arrayInviteStatus.enumerated() {
self.arrayInviteStatus[index] = str.replacingOccurrences(of: "accepted", with: UIImage(name: "accepted.png"))
self.arrayInviteStatus[index] = str.replacingOccurrences(of: "pending", with: UIImage(name: "pending"))
}
Thank you for your help.