nspopup错误地将numberOfItems记录为0

时间:2014-08-10 18:10:21

标签: objective-c macos nspopupbutton

我有一个填充了arraycontroller的NSPopUpButton。 当我运行一个nslog来询问[popup numberOfItems]它打印0时,即使程序运行时,我也会查看弹出窗口中填充的3个菜单项。因此,在填充菜单之前必须打印日志。

NSPopUpMenu何时填充,如何更改完成的时间?

1 个答案:

答案 0 :(得分:0)

想出来。 即使检查了“自动准备内容”,也会延迟到awakeFromNib和windowControllerDidLoadNib:load之后。

根据苹果文档:

This can create a problem if you want to perform an operation with the contents of an object controller in either of these methods, since the controller's content is nil. You can work around this by executing the fetch "manually" with fetchWithRequest:merge:error:.