[NSNumber] -> String 변환

let numbers: [NSNumber] = [1,2,3,4,5]

let stringArray = numbers.compatMap { $0.stringValue }
print(stringArray) // ["1"],["2"],["3"],["4"],["5"]

let numberString = stringArray.joined()
print(numberString) // "12345"

/*
한줄로 요약하면
*/

let numberString = numbers.compatMap { $0.stringValue }.joined()
print(numberString) // "12345"

+ Recent posts