views:

144

answers:

5

Hi all, i am creating a python server socket that sends data to the client reguarding files status... what i have is a list containing dictionaries:

[{'Status': '[2,5%]', 'File': 'SlackwareDVD.iso'},
 {'Status': '[21,8%]', 'File': 'Ubuntu_x86.iso'}]

the socket, when asked, sends this data, obviously it is sent as a string type.. i was trying to figure out how i could pass this data in OBJC in corrispective NSarray and NSDictionaries...

anyone have a clue?? hints?? :D Thanks

PirosB3

+1  A: 

Convert it to an XML property list and Cocoa will do the rest.

Azeem.Butt
Correct. XML, JSON, any **standard** format (not Python's `str` since that's language-independent, nor uniquely parseable) would be suited for this.
Wim
This is so genious... why didn't i think of it? i have always done it do get around situations as these!Thanks
PirosB3
A: 

Assuming you have access to the python codebase, generating an XML Property List is trivial from Python.

See Understanding XML Property Lists in the Apple documentation for more information.

I would be surprised if someone hasn't already written something that'll convert Python property lists into NSDictionary compatible XML property lists.

bbum
+1  A: 

A binary way to transport common types is using the Hessian protocol which is available for the iPhone here. I'm not sure what the status of the python implementations are, I can find two (1, 2)

Using it makes it very easy to encode and decode messages.

epatel
A: 

Thanks for all the answers guys :D great!

PirosB3
+2  A: 

Seems perfectly suited for JSON. On the python side use any of the popular json libraries - for example, simplejson - to convert your python data to json, and on the iPhone side use an iPhone json library to convert it to local data representations. Here's an article that shows how to do that.

Parand
great, did it in JSON at the end
PirosB3