1
UIWindow *second = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
NSMutableArray *wArray = [NSMutableArray arrayWithArray:[UIApplication sharedApplication].windows];
[wArray addObject:second];
[[UIApplication sharedApplication] setValue:wArray forKey:@"windows"];

This code crashed after KVC. I just want to test UIApplication's windows property.

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Y Robin
  • 80
  • 1
  • 6

1 Answers1

0

In Application.h class you will find about window

@property(nullable, nonatomic,readonly) UIWindow *keyWindow;
@property(nonatomic,readonly) NSArray<__kindof UIWindow *>  *windows;

which clearly says that windows are readonly. So, you cant set/override any value for windows.

Jamil
  • 2,977
  • 1
  • 13
  • 23
  • UINavigationController's navigationBar and UITabBarController's tabBar.They are both readonly,but they can replace by custom bar through KVC. I don't – Y Robin Oct 18 '15 at 05:16
  • if you write [UIApplication sharedApplication].windows = wArray; – Jamil Oct 18 '15 at 05:34
  • same error will show for self.navigationController.navigationBar = navBar; – Jamil Oct 18 '15 at 05:36
  • actually you don't customise "navigation bar" but you can do "self.navigationItem.titleView = customView;" which you may demand to customise "Navigation Bar" – Jamil Oct 18 '15 at 05:39