Reputation: 53
Hi in the log window I have two array.First one is my colored one as you can see the simulator blue ones.I want to change/replace blue ones with the second array but they are my chords .
Actually I tried like in following codes but all blue text changed with "Dbm" that was the second array's first string.
for txt in coloredTexts {
for transposed in transposedAkorArray{
self.akor_goster.text = self.akor_goster.text.replacingOccurrences(of: "\(txt)", with: "\(transposed)")
}
}
Upvotes: 2
Views: 50
Reputation: 1656
I think you are trying to do something like this:
for i in 0..<coloredTexts.count {
self.akor_goster.text = self.akor_goster.text.replacingOccurrences(of: "\(coloredTexts[i])", with: "\(transposedAkorArray[i])")
}
Upvotes: 2
Reputation: 24341
Try,
for (index,txt) in coloredTexts.enumerated() {
let range = akor_goster.text.range(of: txt)
akor_goster.text.replacingOccurrences(of: txt, with: transposedAkorArray[index], options: [], range: range)
}
Upvotes: 2