Fixed the crash due to separate thread :
-(void)viewDidLoad{
NSOperationQueue *operationQueue = [[NSOperationQueue alloc]init];
NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(load) object:nil];
[operationQueue addOperation:operation];
[operation release];
[operationQueue release];
}
-(void)load {
[NSThread sleepForTimeInterval:1];
[self performSelectorOnMainThread:@selector(loadWebView) withObject:nil waitUntilDone:NO];
}
-(void)loadWebView{
NSLog(@"Runnnnn....");
UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];
[webView setUserInteractionEnabled:YES];
NSString *docsDirectory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask, YES) objectAtIndex:0];
NSString *newDirectory = [NSString stringWithFormat:@"%@/E-Bills", docsDirectory];
NSString *file = [newDirectory stringByAppendingPathComponent:@"eBill.pdf"];
NSURL *targetURL = [[NSURL alloc] initFileURLWithPath:file];
NSURLRequest *request = [NSURLRequest requestWithURL:targetURL];
[webView loadRequest:request];
[self.view addSubview:webView];
[targetURL release];
[webView release];
}
Comments
Post a Comment