首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >MonoTouch NSKeyedUnarchiver

MonoTouch NSKeyedUnarchiver
EN

Stack Overflow用户
提问于 2013-04-12 13:35:17
回答 1查看 603关注 0票数 0

在Monotouch中寻找NSKeyedUnarchiver的帮助

在SQLite blob字段中存储字典项数组

IOS代码

代码语言:javascript
复制
NSData     *data = [[NSData alloc] initWithBytes:ptr length:size];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
NSMutableArray *myArray = [unarchiver decodeObjectForKey:@"pricing"];
[unarchiver finishDecoding];
NSMutableArray *MutData = [[NSMutableArray alloc] init];
for (NSDictionary *obj in myArray) {
     NSMutableDictionary *element = [[NSMutableDictionary alloc] initWithDictionary:obj];
     [MutData addObject:element];
}

尝试转换为MonoTouch,到目前为止我已经

MonoTouch码

代码语言:javascript
复制
NSData data = NSData.FromString(item.pricing);

NSKeyedUnarchiver unarchive =  new NSKeyedUnarchiver(data);
unarchive.DecodeObject();
unarchive.FinishDecoding();

NSMutableArray array = unarchive.GetNativeField("pricing") as NSMutableArray;
NSMutableArray mutArray = new NSMutableArray();

for (uint count=0; count < array.Count; count++)
{
    NSMutableDictionary mutDict = new NSMutableDictionary(array.ValueAt(count));
    mutArray.Add(mutDict);
}

在运行时生成和错误

未处理的托管异常:Objective异常抛出。名称:* /Developer/MonoTouch/Source/monotouch/src/Foundation/NSKeyedUnarchiver.g.cs:88 initForReadingWithData:* -NSKeyedUnarchiver initForReadingWithData::无法理解的存档(0x62、0x70、0x6c、0x69、0x73、0x74、0x30、0x30) (MonoTouch.Foundation.MonoTouchException)位于MonoTouch.Foundation.NSKeyedUnarchiver..ctor (MonoTouch.Foundation.NSData data) 0x00027 at MonoTouch.Foundation.NSKeyedUnarchiver..ctor(MonoTouch.Foundation.NSData data)

来自新的NSKeyedUnarchiver(数据)行

有人能为MonoTouch NSKeyedUnarchiver推荐教程/示例吗?

有人能帮我解决这个错误吗?

最后,这是实现该项目跨平台并在Android (最终)下工作的最佳方式吗?

提前感谢

EN

回答 1

Stack Overflow用户

发布于 2013-04-13 03:21:23

问题可能在于您如何创建初始NSData。

是NSData.FromString所做的,它看起来不太像在Objetive-C中所做的工作。

如果在C#中有可用的指针,请尝试使用NSData.FromBytes

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15972792

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档