Ans:
Convert character array to string :
let characterArray: [Character] = ["i", "o", "s", "i", "q", "a", ".", "c", "o", "m"]
let string = String(characterArray)
print(string)
// prints "iosiqa.com"
Convert string array to String :
let stringArray = ["iosiqa", ".", "com"]
let characterArray = stringArray.flatMap { String.CharacterView($0) }
//let characterArray = stringArray.flatMap { $0.characters } // also works
let string = String(characterArray)
print(string)
// prints "iosiqa.com"
Convert character array to string :
let characterArray: [Character] = ["i", "o", "s", "i", "q", "a", ".", "c", "o", "m"]
let string = String(characterArray)
print(string)
// prints "iosiqa.com"
Convert string array to String :
let stringArray = ["iosiqa", ".", "com"]
let characterArray = stringArray.flatMap { String.CharacterView($0) }
//let characterArray = stringArray.flatMap { $0.characters } // also works
let string = String(characterArray)
print(string)
// prints "iosiqa.com"
No comments:
Post a Comment
Thanks