Ser*_*gio 3 cocoa serialization nsdata deserialization
我正在使用AsyncSocket的客户端/服务器应用程序.对于传输数据,它使用NSData.
如何将包含NSNumbers,NSIntegers和NSStrings的自定义对象插入到NSData对象中然后将其取出?
将自定义对象插入(序列化)到NSData对象的一种方法是使用NSCoding和NSKeyedArchiver.
首先,让您的自定义对象实现NSCoding协议.
示例:http:
//developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Archiving/Articles/codingobjects.html#//apple_ref/doc/uid/20000948-97234
然后,有关在NSKeyedArchiver中使用对象的信息,请参阅:http:
//developer.apple.com/library/ios/#documentation/Cocoa/Conceptual/Archiving/Articles/creating.html
希望有所帮助!