Objective-C相当于UnsafePointer <cchar>

时间:2016-07-11 02:15:45

标签: objective-c swift

我尝试在Objective-C上写下this tutorial上写的Swift代码。

我几乎把所有这些都写到了Objective-C,除了这部分:

let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)

我的问题是如何将这部分从Swift写入Objective-C?

1 个答案:

答案 0 :(得分:1)

请记住,Objective-C是C的超集,所以你可以在这里找到答案:

Interacting with C APIs

C Syntax          | Swift Syntax
------------------+----------------------------
char, signed char | CChar
const Type *      | UnsafePointer<Type>

所以Swift UnsafePointer<CChar>是Objective-C const char *