나는 Graham Lee가 저술 한 "Test-Driven iOS Development"를 따르고 있으며,이 섹션에서는 전혀 설명되지 않았습니다. 이 아이디어는 을 didFinishLaunchingWithOptions
에서 인스턴스화하는 것이 아니라 IBOutlet을 사용하여 UIWindow
xib 파일에 연결하는 것입니다. 나는 그 일을 할 수없고 인터넷에서 어떤 예를 찾을 수 없다.어떻게 단위 테스트 didFinishLaunchingWithOptions?
-(void)testWindowHasRootNavigationControllerAfterApplicationLaunch
{
XCTAssertEqualObjects(window.rootViewController, navigationController, @"App delegate's navigation controller should be the root VC");
}
@implementation iTagNewsAppDelegateTests
{
UIWindow *window;
UINavigationController *navigationController;
AppDelegate *appDelegate;
}
- (void)setUp {
window = [UIWindow new];
navigationController = [UINavigationController new];
appDelegate = [AppDelegate new];
appDelegate.window = window;
appDelegate.navigationController = navigationController;
}
코드 :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
BrowseOverflowViewController *firstViewController =
[[BrowseOverflowViewController alloc] initWithNibName: nil bundle: nil];
TopicTableDataSource *dataSource = [[TopicTableDataSource alloc]
init];
[dataSource setTopics: [self topics]];
firstViewController.dataSource = dataSource;
self.navigationController.viewControllers =
[NSArray arrayWithObject: firstViewController];
self.window.rootViewController = self.navigationController;
[self.window makeKeyAndVisible];
return YES;
}
@interface BrowseOverflowAppDelegate : NSObject <UIApplicationDelegate>
@property (nonatomic, retain) IBOutlet UIWindow *window;
@property (nonatomic, retain) IBOutlet UINavigationController *navigationController;
@end
그의 전체 프로젝트가 GitHub. 에 사용자 정의 UIWindow
를 정의하는 방법을 어떤 튜토리얼이 있습니까? 많은 감사