views:

386

answers:

2

Hi all,

I'm prototyping a video streaming client for the iphone that gets it's content from a webserver written in C#.

The server outputs an XML document where the jpg data for the image is stored in one of the tags (). It writes it out using WriteBase64.

On the iPhone, I'm using libxml to parse the xml and storing the bytes for the image in an NSString.

The next step is to create an NSData object using the data and then a new UIImage using it's +initWithData method.

However, each time I try to create a new image, the result is a nil object indicating failure. My best guess is that there is something I need to do to convert the NSString back somehow.

Please help!!

+3  A: 

Are you properly base64 decoding your the string from your XML? There is not a native way to do this in Objective-C that I am aware of, but there is a good discussion on how to roll your own here: http://www.cocoadev.com/index.pl?BaseSixtyFour

Greg Martin
Thanks! that did the trick.
mwahab
+1  A: 

An alternate approach would be to attach the image binary data directly after the XML stream and parse it out yourself - base64 encoding really expands the size of the image you are transferring.

Kendall Helmstetter Gelner
I'll definitely be going with that in the next iteration, the base64 encoding stuff was done so the server-side guys could get a working prototype up and running. Thanks!
mwahab