3

Here's what i did.

  1. Make a clean OSX project.
  2. went to main.xib and dragged a popover controller. This created 2 visible objects on on interface builder.
  3. I went to the appDelegate.h file and did

    `-@Property (assign) IBOutlet NSViewController *popVC;

  4. Then i went to the applicationDidFinishLaunching: method and did

    popVC = [[NSViewController alloc] init];

Result: I get the following error message:

enter image description here

Shouldnt objects on a nib be weak since it is already owned by the nib?

4

1 回答 1

11

查看控制器的插座应该是strong. NIB 不拥有这些对象,它只是一个档案。视图的出口通常应该是weak,但这是因为视图由其超级视图保留(超级视图通常由其视图控制器保留)。


顺便说一句,你不应该这样做:

popVC = [[NSViewController alloc] init];

因为popVC在加载 NIB 时正在取消归档、创建和设置。通过自己创建和设置实例,您将丢弃 NIB 版本。这适用于所有插座 - 加载 NIB 时我要填写的插座的目的。

于 2013-06-22T22:53:37.990 回答