目标c中的结构 [英] Struct in Objective c

查看:43
本文介绍了目标c中的结构的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要在目标c中创建四个 Struct 结构

i need to create four Struct in objective c

它们是:

typedef struct FILE_TRANSFER_REQUEST_STRUCT
{
    uint8_t header[16];  // This would be MD5 of String "SymbolTalk"
    uint8_t type;        // Type of structure -> FILE_TRANSFER_REQUEST
    char    fileName[512];
    int     totalSize; //4096
    int     chunkSize; //1024
    int     numChunks; // 4
}FileTransferRequest;

typedef struct FILE_TRANSFER_RESPONSE_STRUCT
{
    uint8_t header[16];  // This would be MD5 of String "SymbolTalk"
    uint8_t type;        // Type of structure -> FILE_TRANSFER_RESPONSE
    ;
}FileTransferResponse;

typedef struct FILE_CHUNK_REQUEST_STRUCT
{
    uint8_t header[16];  // This would be MD5 of String "SymbolTalk"
    uint8_t type;        // Type of structure -> FILE_CHUNK_REQUEST

    uint8_t data[1024];
    uint8_t chunkNumber;
    uint8_t chunkSize;
}FileChunkRequest;

typedef struct FILE_CHUNK_RESPONSE_STRUCT
{
    uint8_t header[16];  // This would be MD5 of String "SymbolTalk"
    uint8_t type;        // Type of structure -> FILE_CHUNK_RESPONSE
    uint8_t chunkNumber;

}FileChunkResponse;

但是我对Objective struct不了解.我该怎么做.在哪里需要创建这个struct(需要避免class).是否将它写在Objective C类文件中.任何人都可以告诉我如何获得这个结构在另一个类中..任何人都可以帮助我...

however i have no idea about Objective struct.how can i do this.where i need to create this struct(need to avoid class).is it write in objective c class file.can any one tell me how can i get this struct in another class..can any one help me...

推荐答案

执行此操作的方式与使用纯C语言时完全相同.将它们放在您的 .h 文件之一中(以任意一个为准)在您的 @interface 块之外,对于它们的用途最有意义.这样,它们就不会成为任何类的一部分.

You would do this exactly the same way as you would in plain C. Put them in one of your .h files (whichever one makes the most sense for what they are used for), outside of your @interface block. Then they will not be part of any class.

要在类中使用它们,只需 #import .h文件中包含您的结构定义.

To use them in a class, just #import the .h file with your struct definition in it.

这篇关于目标c中的结构的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆