NSCoder - 使用多层嵌套数组对数组进行编码
我有一个 mainObjectArray (NSMutableArray),其中填充了自定义类的实例。每个实例本身就是一个数组,每个数组中的对象是 NSDates、NSStrings、BOOL 以及更多包含类似对象的数组。
我无法确定的是,是否可以在
- (void)encodeWithCoder:(NSCoder *)encoder
方法内部简单地说这样的话:
[encoder encodeWithObject:mainObjectArray];
或者是否必须分别对每个实例中的每个对象进行编码?这会有点痛苦......
我们将非常感谢您的帮助。
I have a mainObjectArray (NSMutableArray) which is populated with instances of a custom class. Each instance is itself an array, and objects in each array are NSDates, NSStrings, BOOL, and more arrays containing similar objects.
What I haven't been able to establish is whether it's possible to, inside the
- (void)encodeWithCoder:(NSCoder *)encoder
method, to just say something like that:
[encoder encodeWithObject:mainObjectArray];
Or do have to encode every object in every instance separately? This would be a bit of a pain...
Your help would be very much appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需在您的自定义类中实现编码和解码方法即可。这样就可以了。一些示例,
您可以看到总共三种数据类型被编码和解码 - int、string、array。
希望这有帮助。
Just implement the encoding and decoding methods in your custom class. That will do. Some sample,
You can see totally three data types being encoded and decoded - int, string, array.
Hope this helps.