开发者

Sending NSDictionary between phones

开发者 https://www.devze.com 2022-12-16 00:51 出处:网络
I have an application where a user creates settings that are stored in an NSMutableDictionary. I have to send this to a server, whe开发者_开发百科re it can be later retrieved by a recipient.

I have an application where a user creates settings that are stored in an NSMutableDictionary. I have to send this to a server, whe开发者_开发百科re it can be later retrieved by a recipient.

I can serialize the dictionary, and send it to the server. My question is, if I send it as NSData, store it in a blob field in my postgresql db, and then send it back when requested, is it as simple as using [NSDictionary initWithContentsOfURL]? Is there anything I need to worry about on the server side? http headers sending and receiving?

If I send it as NSDictionary -> serializedData -> xml, so that other devices than iPhones can use it, is there a simple way to recreate the NSDictionary from the xml, or should I store both xml and data, and send the one requested?


Just to be safe, I'd serialize it as a text plist. That's an xml format, so it should be usable anywhere, but is also convertible back to an NSDictionary with one call.

Use -[NSPropertyListSerialization dataFromPropertyList:format:errorDescription:], with NSPropertyListXMLFormat_v1_0 as the format.

0

精彩评论

暂无评论...
验证码 换一张
取 消