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
My suggestion is first to add a property
descriptionin theOfferingobject to handlenameandvalueproperly (your solution puts always a comma betweennameandvalueregardless whethernamehas a value or not)And rather than a loop use
compactMapandjoined