Converting from Swift string to const char*

前端 未结 4 440
渐次进展
渐次进展 2020-12-03 22:54

I\'m trying to pass a const char * to an old C library converted from a Swift string in Swift.

This is the C function I\'m calling:

artnet_node artne         


        
4条回答
  •  情歌与酒
    2020-12-03 23:42

    Simple way for Swift 3

    var ipAddress: String = "192.168.1.43"
    var verbose: Int = 1
    artnet_node artnet_new((ipAddress as NSString).utf8String, verbose)
    

提交回复
热议问题