I am trying to upload data using POST method in ios application.I want to show progressbar indicator while uploading the data. I have progressbar in another view controller and NSURLConnection delegate methods in another class. I have tried as below.
-(void)updateProgressBar:(float)progressBarValue {
NSLog(@"What is the progress bar indicator %f",progressBarValue);
[self performSelectorOnMainThread:@selector(updateProgressOnMainThread) withObject:nil waitUntilDone:NO];
progressBarValueForMinThread = &progressBarValue;
}
- (void)updateProgressOnMainThread {
progressBar.progress = *(progressBarValueForMinThread);
}
Class containing NSURLConnection methods
- (void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite{
NSLog(@"bytesWritten %d",bytesWritten);
NSLog(@"totalBytesWritten %d",totalBytesWritten);
NSLog(@"totalBytesExpectedToWrite %d",totalBytesExpectedToWrite);
progressedIndicator = ((float)totalBytesWritten / totalBytesExpectedToWrite);
NSLog(@"DELEGATE PROGRESS INDICATOR %f",progressedIndicator);
[objUpdatesController updateProgressBar:progressedIndicator];
}
"objUpdatesController" is the object of class containing progress bar. Any help is appreciated.