I need to update a progress bar from view controller lets call him A which is located in view controller B , the update is done when I start a NSULRCONNECTION from B that will access the method DidSendBodyData
defined in view controller A in this method there is the progress bar that should be updated, here is my code in view controller B :
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:[NSBundle mainBundle]];
UINavigationController * myStoryboardInitialViewController = [storyboard instantiateInitialViewController];
HomeViewController *rootViewController = [myStoryboardInitialViewController.viewControllers objectAtIndex:0];
NSURLConnection * connection = [[NSURLConnection alloc]
initWithRequest:request
delegate:rootViewController startImmediately:NO];
this is the code defined in class B, I need reference to view controller A which is here rootViewController
but what is done above is not right because it creates another object of the view controller and not using the existing one which means that a new progress bar will be created and updated and that is not what I want,I need to update the existing one in view controller A
here is my code in view controller A :
-(void)connection:(NSURLConnection *)connection didSendBodyData:(NSInteger)bytesWritten totalBytesWritten:(NSInteger)totalBytesWritten totalBytesExpectedToWrite:(NSInteger)totalBytesExpectedToWrite{
(float)totalBytesWritten ,(float)totalBytesExpectedToWrite);
[progress setProgress:((float)(totalBytesWritten))/totalBytesExpectedToWrite];
}
when the connection is established the method didsendBodyData
is called in view controller A and the progress bar should be updated.
how can I get a reference to view controller A without creating new view controller ?!
thanks in advance for any help.