0

可能重复:
如何使用 GameKit 蓝牙将 NSDictionary(或 plist 文件)作为 NSData 发送?

我正在寻找一种简单的方法来通过蓝牙从运行我的应用程序的一个设备向另一个设备发送 PLIST 文件或 NSDictionary。

如何将 PLIST 文件转换为 NSData(然后可以通过蓝牙发送),然后再将其转换回来?

(如果有人可以让我开始使用一些代码,我将不胜感激。)

4

1 回答 1

0

请在 此处查看答案:https://stackoverflow.com/questions/4107004/how-to-send-an-nsdictionary-or-plist-file-as-nsdata-using-gamekit-bluetooth


您可以使用以下内容将 Plist 转换为 NSData:

`+ (NSData *)dataWithPropertyList:(id)plist format:(NSPropertyListFormat)format options:(NSPropertyListWriteOptions)opt error:(NSError **)error`

这将 NSData 转换为 Plist:

+ (id)propertyListWithData:(NSData *)data options:(NSPropertyListReadOptions)opt format:(NSPropertyListFormat *)format error:(NSError **)error

NSPropertyListSerialization

format可能是NSPropertyListBinaryFormat_v1_0使用最低字节数

于 2010-12-01T20:28:31.647 回答