I'm trying to create a stackview with dynamic number of lables.
I tried with:
let nValues: String = "A , B, C, D"
if let someArray = nValues.components(separatedBy: ",") {
let label: UILabel = UILabel()
for nValue in someArray {
label.text = nValue
label.textColor = .black
nutrientValueLabel?.backgroundColor = .white
myStackView.addSubview(label)
print(nValue)
}
}
But i get only:
A
B
C
D
and empty stackView. I don't know what is my mistake.