I’ve just uploaded some code derived from the Objective-C wrapper I’ve shown in this post. You can find it in the “Projects” section, as usual and it’s simply a wrapper around the URL loading system of Cocoa, both for Macs and iPhones, providing a custom delegate protocol, so that you can handle the events raised by the wrapper:
[source:C::firstline(13)] @protocol WrapperDelegate
@required - (void)wrapper:(Wrapper *)wrapper didRetrieveData:(NSData *)data;
@optional - (void)wrapperHasBadCredentials:(Wrapper *)wrapper; - (void)wrapper:(Wrapper *)wrapper didCreateResourceAtURL:(NSString *)url; - (void)wrapper:(Wrapper *)wrapper didFailWithError:(NSError *)error; - (void)wrapper:(Wrapper *)wrapper didReceiveStatusCode:(int)statusCode;
@end [/source]
The sample project, available in the zip file, shows how a simple Cocoa controller can interact with the Wrapper class as required. Enjoy!
Update, 2008-10-26: After a bug report from StuFF mc I’ve updated the code for a better support of POST and PUT requests, and also added a sample PHP file for a quick test of the functionalities.