I am adding text in UIlabel, & its cost to performance(i have used build time analyser using this link). how can i optimise this code ?
for value in model?.offerings ?? [] {
offeringsLabel.text = offeringsLabel.text! + " | " + (value.name ?? "") + "," + (value.type ?? "")//this addition cost to performance
}
I also tried [ array].joined but that doesn't make any diffrence
Rather than assigning a text to
UILabelin each iteration and reading it again in next one, you can useArray.reduceto first get the full stringSetting
textrepeatedly will hamper performance because, for example, it can trigger size recalculation for dynamically sized labels