so have array of elements of type float. , have uilabel supposed display each of these elements of array on different lines.
the array is
var history = [float]() i used loop go through each element , append uilabel
for(i=0; i<size; i++){ currentstring = string(history[i]) result.text = result.text! + "\n" + currentstring } result uilabel.
i tried using \n doesn't seem recognise it. solutions in swift. in advance!
the first thing check if label has (it stupid mistake, can happen of us)
label.numberoflines = 0 assuming true, instead of building string hand, use in-built function join(). sadly, since not string array, can't use directly, have create string array first
// both storages var history = [float]() // filled data var stringhistory = [string]() // convert each number string value in history { stringhistory.append(string(value)) } // finally, join array 1 string using \n separator let finalstring = "\n".join(stringhistory) hope of helps!
Comments
Post a Comment