Thursday, 11 November 2010

iPhone SDK Troubles - Web Services

«I'm sorry Dave. I'm afraid you have to write it by yourself»

Write a web service should be easier than implement a new protocol. The iPhone SDK is an endless source of surprises to me. I discovered there's no methods to encode a NSString in base64; no library to write easier data and HTTP headers; and just a small C-function to get a MD5 hash. Ok, it's enough to get an hash, but it's not well embedded on Cocoa-Touch.
Ok, I can still write them by my own. But I really can't understand how is possible a network-oriented platform as a smartphone doesn't have this basic functions. Do you think they're not "basic"? Well, Python and PHP have them as built-in modules. And on Android? I found the answer here.
Anyway, a web service on iPhone is just a NSMutableURLConnection, with HTTP headers setted with [theRequest addValue:@"text/xml" forHTTPHeaderField:@"content-type"], passed to a NSURLConnection.
But I will pass the night writting the other necessary functions.
Post a Comment