问题描述
在我的应用程序中,我正在尝试序列化服务器响应字典并将其写入文件系统。但是我收到一些回复的错误属性列表格式无效。原因是服务器响应中的CFNull对象。现在,服务器响应将继续改变,所以我没有明确的方法来删除CFNull对象()。下面是我的代码:
In my application, I am trying to serialize a server response dictionary and writing it to file system. But I am getting error "Property list invalid for format" for some responses. The reason is CFNull objects in the server response. Now, the server response will keep on changing so I do not have a definite way to remove CFNull objects (). Below is my code:
NSString *anError = nil;
NSData *aData = [NSPropertyListSerialization dataFromPropertyList:iFile format:NSPropertyListXMLFormat_v1_0 errorDescription:&anError];
解决此问题的最佳方法是什么?如何一次性从服务器响应中删除所有CFNull对象?
What is the best way to tackle this issue? How can I remove all CFNull objects from server response in one shot?
推荐答案
我切换到NSKeyedArchiver选项。比NSPropertyListSerialization慢一点但是要处理NSNull / CFNull对象。
I switched to NSKeyedArchiver option. Little slower than NSPropertyListSerialization but takes care of NSNull/CFNull objects.
这篇关于在NSPropertyListSerialization中处理CFNull对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!