swift - How do I display strings from an array vertically stacked? -


i trying take each string in array , list them in label 1 string per line. tried using joined method /n attempt make got next line literally puts /n in between each string. i'm sorry if happens duplicate unless i'm wording question wrong cant seem find answer. example of i'm looking for.

string[0]  string[1]  string[2] , on... 

try this:

let array = ["the", "quick", "brown", "fox"]     let string = array.joined(separator: "\n") 

joined returns new string concatenating elements of sequence, adding given separator (in case, line break) between each element in array.

that return this:

the quick brown fox 

...and set yourlabel.numberoflines = 0

from apple's documentation:

the default value numberoflines 1. remove maximum limit, , use many lines needed, set value of numberoflines 0.


Comments

Popular posts from this blog

javascript - Confirm a form & display message if form is valid with JQuery -

Retrieving ETA (estimated time of arrival) with Google Distance Matrix API and public transit as transport mode -

ionic framework - Meteor - Error: Failed to execute 'insertBefore' on 'Node' -