PDA

View Full Version : sending binary data to server... using NSData?




OldGit
Feb 24, 2009, 06:34 AM
I wish to send and receive binary data to a server via POST.

Somehow I need to send two integers (8 bytes), the server then returns binary records which I need to capture.

I have been looking into NSData, the documentation appears to suggest it can receive binary data from a URL with the method "dataWithContentsOfURL" ...

But the only method I see for sending is "writeToURL:atomically:" but the documentation then says "at present only file:// URLs are supported".

Am I barking up the wrong tree with NSData?



kainjow
Feb 24, 2009, 07:51 AM
NSData just holds the data. dataWithContentsOfURL is a convenience method that probably uses NSURLConnection, which is what you need to use. Try this:
http://www.cocoadev.com/index.pl?HTTPFileUploadSample