I wanted to add a view in UIWindow
with following code:
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIWindo
Your windows needs to have a root view controller.
AppDelegate *delegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIWindow *window = delegate.window;
UIViewController *controller = [[UIViewController alloc] init];
window.rootViewController = controller;
UIView *aView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];
aView.backgroundColor = [UIColor blackColor];
[controller.view addSubview:aView];