我目前正在编写一个 RSS 程序,其中我的 splitViewController 的视图必须相互通信。它们目前都持有彼此的属性实例,如下所述,在 App Delegate 中声明。我想知道这是否是不好的编程习惯,如果是,我应该怎么做才能避免它?
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
FCListViewController *lvc = [[FCListViewController alloc]initWithStyle:UITableViewStylePlain];
UINavigationController *masterNav = [[UINavigationController alloc] initWithRootViewController:lvc];
FCContentViewController *cvc = [[FCContentViewController alloc] init];
/*----------------------------------------- */ //<---------My question lies here
[lvc setContentViewController:cvc];
[cvc setListViewController:lvc];
/ ----------------------------------------- /
//[lvc setWebViewController:wvc];
//[[lvc navigationItem]setTitle:@"Falcon RSS Feed"];
// [[self window] setRootViewController:masterNav];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
UINavigationController *detailNav = [[UINavigationController alloc] initWithRootViewController:cvc];
NSArray *vcs = [NSArray arrayWithObjects:masterNav, detailNav, nil];
UISplitViewController *svc = [[UISplitViewController alloc] init];
[svc setDelegate:cvc];
[svc setViewControllers:vcs];
[[self window]setRootViewController:svc];
[[svc view] setBackgroundColor:[UIColor clearColor]]; //eliminates annoying black background for the listViewController when rotated
}
else{
[[self window] setRootViewController:masterNav];
}
UIColor *blueHue = [UIColor colorWithRed:.2 green:.3 blue:.5 alpha:.7];
self.window.backgroundColor = blueHue; //Sets upper most background.. noticed when rotating
[self.window makeKeyAndVisible];
return YES;
}