i need to display a timer in the background for the webrequest loading time in the minutes:seconds format.When the webrequest is loaded successfully the timer has to stop.My code is here:
@interface TimerWithWebrequestViewController : UIViewController {
IBOutlet UIWebView *webView;
IBOutlet UILabel *lbl;
int mainInt;
NSTimer *randomMain;
}
@property(nonatomic,retain) UIWebView *webView;
-(void)upDate;
@end
@implementation TimerWithWebrequestViewController
@synthesize webView;
-(void)viewDidLoad
{
NSString *urlAdd = @"http://www.google.com";
NSURL *url = [NSURL URLWithString:urlAdd];
NSURLRequest *reqObj = [NSURLRequest requestWithURL:url];
[webView loadRequest:reqObj];
[self performSelectorInBackground:@selector (upDate) withObject:nil];
}
-(void)upDate
{
mainInt = 0;
randomMain = [NSTimer scheduledTimerWithTimeInterval:0.1 target:self selector:@selector(randomMainVoid) userInfo:nil repeats:YES];
}
-(void)randomMainVoid{
mainInt += 1;
lbl.text = [NSString stringWithFormat:@"%d",mainInt];
}