szu szu - 9 months ago 76
iOS Question

How to define char array in Swift language

Here is my C code in an Objective-C method

char addressBuffer[100];

But how to define this char in Swift language?

I try something like this but this doesn't work:

var addressBuffer : CChar(100)

Here is the documentation


that is the way to get a nice unicode character array in Swfit:

var charArray: Array<Character> = Array(count: 100, repeatedValue: "?")

if fills your array with 100 question marks, initially.


with CChar, for instance:

var charArray: Array<CChar> = Array(count: 100, repeatedValue: 32) // 32 is the ascii space