複数回呼び出さ私はこのawakeFromNibメソッドは、私のNSPersistenDocumentで
myDocument (NSPersistentDocument) -> myDocument.xib (windows xib)
|
|-> view (the self.view) --> ... "other view"
|
|-> some NSArrayController
|
|-> myResourceViewController --> myResourceViewController.xib
|
|-> view (the self.view)
|
|-> myTreeController (a NSTreeController subclass)
のような構造を持っているベースのプロジェクトは、基本的には、myResourceViewControllerはresourceViewを管理し、そのデータを管理するのViewControllerのインスタンスです。マイドキュメントのawakeFromNib方法で
私が持っているmyResourceViewController awakeFromNibの方法で、次のコード
- (void)windowControllerDidLoadNib:(NSWindowController *)aController
{
...
[leftBar addSubview:resourceViewController.view]; //i add resourceViewController's view
resourceViewController.view.frame = leftBar.bounds;
...
}
を有する:
-(void)awakeFromNib;
{
NSLog(@"%@", [self description]);
[removeButton bind:@"enabled" toObject:resourceTreeController withKeyPath:@"selection" options:[NSDictionary dictionaryWithObject:NSIsNotNilTransformerName forKey:NSValueTransformerNameBindingOption]];
NSArray *draggedTypes = [NSArray arrayWithObjects:ResourceURIPasteBoardType, nil];
[resourceOutlineView registerForDraggedTypes:draggedTypes];
}
のNSLogはawakeFromNibは、myResourceViewControllerの同じインスタンス、呼び出されることを言います4時間、私はなぜ理解していない。私の唯一のResourceViewControllerはmyDocument xibで作成されています。どこでもNSNibのロードメソッドを使用しません。
本当に同じオブジェクトですか? 'NSLog(@"%p%@ "、self、[self description])'を試してください。 – hamstergene
はい、私はNSLog(@ "%@"、[self description])でチェックします。 –
myDocument.xibは唯一のnibですか? – paulmelnikow