使用 TouchJson 序列化字典时出现问题
我正在为 ipad 开发一个小应用程序,我正在尝试将字典序列化为 NSData 以保存在磁盘中。我正在使用 TouchJson 框架。 我的示例结构的示例:
{
line = {
78986928 = (
"NSPoint: {442, 266}",
(...)
"NSPoint: {370, 634}"
);
};
}
我的字典的结构是:内部有字典的字典。该字典有一个字符串(ID)和一个带有 NSValue 的 NSMutableArray。
我正在使用的代码行是:
NSData *jsonData = [[CJSONSerializer serializer] serializeObject:templates error:&error];
变量错误给我的错误是:
2011-03-23 10:12:12.957 GestureFramework[286:207] Error Domain=TODO_DOMAIN Code=-1 "Could not serialize object '{
line = {
78986928 = (
"NSPoint: {442, 266}",
(...)
"NSPoint: {370, 634}"
);
};
}'" UserInfo=0x4e27aa0 {NSLocalizedDescription=Could not serialize object '{
line = {
78986928 = (
"NSPoint: {442, 266}",
(...)
"NSPoint: {370, 634}"
);
};
}'}
Thnx in进步
i'm developing a small app for the ipad and i'm trying to serialize a dictionary to NSData to save in the disk. I'm using with framework TouchJson.
And example of my example structure:
{
line = {
78986928 = (
"NSPoint: {442, 266}",
(...)
"NSPoint: {370, 634}"
);
};
}
The structure of my dictionary is: an dictionary with dictionaries inside. This dictionaries have a string (ID) and an NSMutableArray with an NSValue.
The line of code is that i'm using is:
NSData *jsonData = [[CJSONSerializer serializer] serializeObject:templates error:&error];
The error that the variable error give me is:
2011-03-23 10:12:12.957 GestureFramework[286:207] Error Domain=TODO_DOMAIN Code=-1 "Could not serialize object '{
line = {
78986928 = (
"NSPoint: {442, 266}",
(...)
"NSPoint: {370, 634}"
);
};
}'" UserInfo=0x4e27aa0 {NSLocalizedDescription=Could not serialize object '{
line = {
78986928 = (
"NSPoint: {442, 266}",
(...)
"NSPoint: {370, 634}"
);
};
}'}
Thnx in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
TouchJSON 支持序列化以下类型:
如果您想序列化其他类型,则需要实现
-(NSData*)JSONDataRepresentation
(在子类或类别上)。这是我用于
NSDate
的示例:
TouchJSON supports serializing the following types:
If you'd like to serialize another type you'll need to implement
-(NSData*)JSONDataRepresentation
(either on a subclass or category).Here's an example that I used for
NSDate
:.