3

See the following code, I need to do mock in logic testing, the difficulty is that [UIApplication sharedApplication] always return nil, how do you smart guys resolve this issue? Thank you.

    UIWindow* root = [UIApplication sharedApplication].delegate.window;
    UIWebView *aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 0, 0)];
    [aWebView setDelegate:tracker];
    [aWebView loadRequest:request];
    [root addSubview:aWebView];
    [aWebView release], aWebView = nil;
jianhua
  • 1,011
  • 1
  • 12
  • 28

0 Answers0