在基于文档的 cocoa 应用程序中将 arrayControlle 绑定到 NSViewControllerr 导致多次调用 NSViewControllerr init(code :)

bind arrayControlle to NSViewControllerr in Document-based cocoa app cause the NSViewControllerr init(code :) called many times

我正在开发一个基于文档的 cocoa 应用程序使用核心数据,我像这样将 NSViewController 绑定到 NSArrayController :

https://developer.apple.com/library/archive/qa/qa1871/_index.html ,

,当我在文档中保存一些NSManagedObject然后从保存的文档中读取数据时,模型可以从保存的文档中读取,但是NSViewController被创建了很多次,例如,如果我在文档中保存了7个NSManagedObject ,然后我打开保存的文档,我可以得到保存的7个NSManagedObject,但是NSViewController会创建7次,怎么办?谢谢

我解决了,因为我的 FUEAttributeVCBaseModelMO class 有一个属性“@NSManaged public var owner: FUEAttributeViewController?”,当我重新打开现有文档时,如果文档有 FUEAttributeVCBaseModelMOs,对象FUEAttributeVCBaseModelMO 将调用 FUEAttributeViewController init.