Q:

Simple Browserlaunch taking very long time

I have an app which simply launches browser with a link and closes itself.
Here is the code:
#import "ViewController.h"

@implementation ViewController

-(void)viewDidLoad
{
    [super viewDidLoad];

    self.view.backgroundColor= [UIColor cyanColor];
    mLinkview = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 480)];
    [mLinkview setDelegate:self];        

    NSURL *url = [NSURL URLWithString:@"http://www.mediklean.com"];
    [[UIApplication sharedApplication] openURL:url];
    exit(0);        

    [self.view addSubview:mLinkview];
    // Do any additional setup after loading the view, typically from a nib.
}

-(void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}    
@end

The problem is , it's taking very long time , like 10 seconds before launching the browser. Can anyone help if this is a problem caused by code or something else?.

A:

Launch the browser in your viewDidAppear method. It will minimize your delay.
-(void)viewDidAppear:(BOOL)animated {

    [super viewDidAppear:animated];
    NSURL *url = [NSURL URLWithString:@"http://www.mediklean.com"];
    [[UIApplication sharedApplication] openURL:url];
    exit(0);
}

