Very very light NSURLConnection wrapper. For when you just need to download some data in the background.
Objective-C
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
DMURLConnection.h
DMURLConnection.m
NSDictionary+URLEncoding.h
NSDictionary+URLEncoding.m
README

README

DMURLConnection

For when you just need to download some data. Sort of.

DMURLConnection has only been used on the iPhone.
DMURLConnection does a weird self-retain.
DMURLConnection retains its delegate.
DMURLConnection is self-released when either of its delegate methods are called.

Comments, contributions, questions, all are welcome.

Example usage:
-(void)getConfigFile {
	NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:SETTINGS_URL]];
	[urlRequest setHTTPMethod:@"POST"];

	NSMutableDictionary *dict = [NSMutableDictionary dictionaryWithCapacity:3];
	[dict setValue:[[UIDevice currentDevice] uniqueIdentifier] forKey:@"UUID"];
	[dict setValue:@"parameter value" forKey:@"parameter key"];
	[dict setValue:@"pvalue2" forKey:@"pkey2"];
	
	NSDictionary *staticDict = [NSDictionary dictionaryWithDictionary:dict];
	[urlRequest setHTTPBody:[staticDict urlEncodedDataUTF8]];

	[DMURLConnection connectToRequest:urlRequest withDelegate:self];
}

Delegate methods:
-(void)connectionFinishedLoadingWithData:(NSMutableData *)rd; // manditory
-(void)connectionFailedWithError:(NSError *)error; // optional

Blocks:
I just added a blocks interface.
+(id)connectToRequest:(NSURLRequest *)req withBlock:(StateChangeBlock)stateChanged;

StateChangedBlock takes two parameters, (id)data and (NSError *)error.
If data is nil, NSError will have an error, otherwise you can continue with the data object.
All reference to blocks is dependent on NS_BLOCKS_AVAILABLE, so it should compile for iOS 3 still.

Helper:
urlEncodedDataUTF8 is a category on NSDictionary. It's included for convenience, but you may or may not need it.

License:
Any use is fine, with two caviats,
-If you improve on the code, share.
-If you use it in something that ships, let me know.