NSMutableData *receiveData;
- (void) sendData : (NSString *) url : (NSString *) value : (NSString *) sendType {
NSMutableURLRequest *request = [[NSMutableURLRequest alloc] init];
NSString *post = value;
NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
[request setURL:[NSURL URLWithString:url]];
[request setHTTPMethod:sendType];
[request setHTTPBody:[value dataUsingEncoding:NSUTF8StringEncoding]];
[request setCachePolicy:NSURLRequestUseProtocolCachePolicy];
[request setTimeoutInterval:15.0f];
[request setValue:@"Mozilla/4.0 (compatible;)" forHTTPHeaderField:@"User-Agent"];
[request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
[request setHTTPBody:postData];
NSURLConnection *connection = [NSURLConnection connectionWithRequest : request
delegate : self];
}
// Receive Start to Submit
- (void) connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *) aResponse {
NSLog(@" Receive Start ");
receiveData = [[NSMutableData alloc] init];
}
// Connection Error Event
- (void) connection:(NSURLConnection *)connection didFailWithError:(NSError *) error {
[self setRetryGetData];
NSLog(@" Receive Error ");
}
// Connection Receive Event
- (void) connection:(NSURLConnection *)connection didReceiveData:(NSData *) data {
NSLog(@" Receiving............ ");
[receiveData appendData:data];
}
// Connection Receive Finished
- (void) connectionDidFinishLoading : (NSURLConnection *) connection {
NSLog(@" Receive Finished ");
NSLog(@" Receive Data : %@", receiveData);
}