I want send to the data on the server in batches. I have to send nsmutablestring data with 25 strings at a time then get response and if the response is success then again send the next batch. I am using HTTPConnection class.The code that I am using is like:
HttpConnectionClass * ht= [[HttpConnectionClass alloc] init];
ht.delegate=self;
ht.isNetworkIndicator = YES;
NSString *data = @"" ;
int i = 0;
self.dataforserver = [[NSMutableString alloc]init] ;
[self.dataforserver setString:@""];
for (i=0;i<= self.dataArray.count-1; i++) {
data =[NSString stringWithFormat:@"A%d%@",[[self.recordIDArray objectAtIndex:i]intValue], [self.dataArray objectAtIndex:i]];
[self.dataforserver appendString:data];
if ((i+1)%25 == 0 && i!=0 ) {
[ht makeHttpConnection:[NSString stringWithFormat:@"http://www.url.com?action=%d&subscriberid=%d&type=%@",2,56904,@"full"] withData:self.dataforserver];
NSLog(@"in for loop dataforserver is %@",dataforserver);
[dataforserver setString:@""];
}
}
if (dataforserver != @"" ) {
NSLog(@"not in for loop dataforserver is %@",dataforserver);
[ht makeHttpConnection:[NSString stringWithFormat:@"http://www.url.com?action=%d&subscriberid=%d&type=%@",2,56904,@"full"] withData:self.dataforserver];
}
I am getting response in the following method
-(void)getHttpData:(NSObject*)data isError:(BOOL)isErr errorMsg:(NSString*)err{
NSString *response=(NSString*)data;
NSLog(@"response is %@",response);
}
I want to continue the loop only if I get the response "SUCCESS". Can anyone suggest how to achieve it. I am very new to iOS programming.Please help