iphone - Extracting array from NSMutableData in http response -


using iphone sdk 4.0. Returns the callback data as an NSData object for an HTTP request

  - (zero) connection: (NSURLConnection *) connection was reception: (NSDT *) data {// Our data Attach data to [data and data: data]; }  

In my PHP script on the server I am returning an array as the following

  var_dump ($ array)  

How can I get my array back to my iPhone from the NSMutableData object 'data' ipod?

Thanks

Your array stored in the sequence of bytes in your NSMTLD data object (Or maybe several arrays?) Is the string that describes. To convert it back into an array, you will need to parse the var_dump output which can be harder.

If you have a library (or your code) to return your data to the Apple Plast format Your work will be very simple: you can

  NSPropertyListSerialization propertyListFromData: mutabilityOption: format: errorDescription:]  

that is an NSData (or NSMutableData) takes the pointer as its first argument, trying for the starting point Not.


From the example code on the cfpropertylist page:

  $ plist = new CFPropertyList (); $ TD = new CFTypeDetector (); $ Estimated Structure = $ td- & gt; ToCFType ($ array); $ Plist- & gt; Add ($ Estimated Structure); // and then plist-> $ plist-> toXML ()  

and return plist content with your iOS code:

  NSString * errorString = void ; NSArray * array = [[NSPropertyListSerialization propertyListFromData: theData mutabilityOption: NSPropertyListImmutable Format: Zero error description: & amp; Error string]];  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -