1

我在 Snow Leopard 上运行 xcode 4.2。我正在尝试在 Mac 应用程序中调出一个面板,该面板将显示在主窗口旁边。这是代码:

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
    _propertiesViewController = [[NSViewController alloc] initWithNibName:@"FFPropertiesViewController" bundle:nil];
    _panelController = [[NSWindowController alloc] initWithWindowNibName:@"FFPropertiesPanel"];
    [(NSPanel*)[_panelController window] setBecomesKeyOnlyIfNeeded:YES];
    [[_panelController window] setContentView:[_propertiesViewController view]];
    [_panelController showWindow:self];

}

该面板似乎运行良好,其控件似乎可以正常工作。但是后来,当我创建一个自定义对象并尝试将其分配给 NSViewController 的代表对象属性时,分配不会发生。执行以下行会将代表对象的值保留为 nil:

_propertiesViewController.representedObject = aFieldInfo;

我尝试为 ViewController 提供一个属性来引用 FieldInfo 对象,并在我尝试分配代表对象的同一位置分配该属性。效果是一样的——在赋值之后 fieldInfo 属性的值保持为 nil。这让我觉得 ViewController 有问题。也许我错误地从笔尖中检索到它?

谢谢

4

0 回答 0