编码C结构 [英] Encoding C Structs

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

问题描述

我有一个结构定义像下面作为一个对象的一部分。我试图编码这与NSCoder使用的目的是保存以及撤消/重做功能。

I have a struct defined like follows as part of an object. I'm trying to encode this for use with NSCoder with the aim of saving as well as Undo/Redo functionality.

struct myCol {
    float rd;
    float grn;
    float blu;
    float alp;
} toolColor;

-encodeBool: -encodeFloat: -encodeObject:

推荐答案

我认为你应该考虑你的struct myCol作为内存缓冲区和编码它由像 encodeBytes 函数。缓冲区长度=结构大小

I think you should consider you struct myCol as memory buffer and encode it by something like encodeBytes function. Buffer length = size of your struct

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

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