看下面的代码,我需要在逻辑测试中做模拟,难的是[UIApplication sharedApplication]总是返回nil,你如何聪明地解决这个问题?谢谢。
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;