szu szu - 1 year ago 157
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

Answer Source

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
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download