看下面的代码,我需要在逻辑测试中做mock,难点是[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;