解析 XML 后的 NSPropertyListSerialization
我需要知道我是否走在正确的轨道上。我正在 iPhone 中解析 XML-RPC(使用 eczarny 框架),并且得到一个包含对象的数组。我创建一个 NSData 并存储一个对象。之后我尝试反序列化它但出现错误。 代码:
NSArray *result = [response object];
NSData *data = [result objectAtIndex:0];
NSLog(@"Data %@",data);
NSDictionary * message = nil;
NSString * error = nil;
message = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainers format:nil errorDescription:&error];
nslog:
Data {
DESCRIPTION = "Standardverkn";
FLAGS = 0;
NAME = "Fenster OG3";
RECEIVER = "IEQ007:3";
SENDER = "IEQ0043:1";
}
错误:
-[__NSCFDictionary length]: unrecognized selector sent to instance 0x6e4bd50
我做错了什么?
I need to know if I am in the right track here. I am parsing an XML-RPC in iPhone (using the eczarny framework) and I am getting an array with objects. I create an NSData and store an object. After that I am trying to deserialize it but get en error.
Code:
NSArray *result = [response object];
NSData *data = [result objectAtIndex:0];
NSLog(@"Data %@",data);
NSDictionary * message = nil;
NSString * error = nil;
message = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListMutableContainers format:nil errorDescription:&error];
The nslog:
Data {
DESCRIPTION = "Standardverkn";
FLAGS = 0;
NAME = "Fenster OG3";
RECEIVER = "IEQ007:3";
SENDER = "IEQ0043:1";
}
The error:
-[__NSCFDictionary length]: unrecognized selector sent to instance 0x6e4bd50
What am I doing wrong?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
[result objectAtIndex:0]
已经是一个 NSDictionary。您不需要反序列化它。您可以直接将其用作消息
。(如果它是 NSData,则 NSLog 将显示类似
<12345678 9abcdef0 ...>
的内容。)[result objectAtIndex:0]
is already an NSDictionary. You don't need to deserialize it. You can just directly use it as themessage
.(If it is an NSData, the NSLog will show something like
<12345678 9abcdef0 ...>
.)