What is the new way of binding an NSArrayController to the managed object context of a Core Data document?

后端 未结 4 610
伪装坚强ぢ
伪装坚强ぢ 2020-12-24 09:09

Before Xcode went and added Storyboards for OS X apps you could connect an array controller to your document\'s managed object context by binding the Managed Object Co

4条回答
  •  夕颜
    夕颜 (楼主)
    2020-12-24 09:18

    You have always been able to bind through NSApplication with a keypath of delegate.managedObjectContext if the application delegate owns the core data stack. Otherwise you could pass pass the MOC through to each view controller with a MOC property on each one, which is strongly preferred by those who argue that the app delegate shouldn't be used to own singleton MOCs, and that there's further utility in being able to provide each VC a separate MOC.

    I believe you could also create a MOC instance in the storyboard in IB. There's also always been a MOC object for nibs, at least. Though I haven't used that enough to know how it relates to a programmatic core data stacks. Probably better to just have a MOC property somewhere you can access in either the VC hierarchy or app delegate

提交回复
热议问题