I know how to programmatically do it, but I'm sure there's a built-in way...
Every language I've used has some sort of default textual representation for a collection of objects that it will spit out when you try to concatenate the Array with a string, or pass it to a print() function, etc. Does Apple's Swift language have a built-in way of easily turning an Array into a String, or do we always have to be explicit when stringifying an array?
Create extension for an
Array
:if you have string array list , then convert to Int
it will give you string value
A separator can be a bad idea for some languages like Hebrew or Japanese. Try this:
For other data types respectively:
FOR SWIFT 3:
With Swift 3, according to your needs, you may choose one of the following blocks of code.
Turning an array of
Character
into aString
with no separator:Turning an array of
String
into aString
with no separator:Turning an array of
String
into aString
with a separator between words:Turning an array of
String
into aString
with a separator between characters:Turning an array of
Float
into aString
with a separator between numbers:Mine works on NSMutableArray with componentsJoinedByString