Byte array in objective-c

前端 未结 2 429
轮回少年
轮回少年 2020-12-10 12:36

How can I create a byte array in Objective-C?

I have some data like this:0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x78, 0x89, 0x12, 0x23, 0x34, 0x45, 0x56, 0x67, 0x

相关标签:
2条回答
  • 2020-12-10 13:10

    Either use the plain C solution given by mouviciel or read the class description of NSData and NSMutableData.

    0 讨论(0)
  • 2020-12-10 13:15

    You can simply use plain C syntax, which is available in Objective-C:

    const char myByteArray[] = {
        0x12,0x23,0x34,0x45,
        0x56,0x67,0x78,0x89,
        0x12,0x23,0x34,0x45,
        0x56,0x67,0x78,0x89 };
    
    0 讨论(0)
提交回复
热议问题