MainWindow.xibのFiles Ownerはだれ?
HogeViewControllerにhoge.nibを指定すると、hoge.nib内のFile's OwnerはHogeViewControllerのオブジェクトになる。
じゃあ、Main nib fiileに指定したNIBファイルのFile's Ownerは何になるのかしらと思ったので調べてみた。
// AnViewController.h ... @interface AnViewController : UIViewController { id owner; } @property (retain, nonatomic) IBOutlet id owner; - (IBAction)inspectOwner; @end ... // AnViewController.m ... @implementation AnViewController @synthesize owner; -(IBAction)inspectOwner { NSLog(@"File's Owner: %@", owner); } ...
出力されたログを見てみたらUIApplicationとのこと。そうかMain nibはUIApplicationの中でロードされるのだなぁと納得した。
2009-07-29 06:51:21.198 [16946:20b] File's Owner: <UIApplication: 0x520820>