xcode - How to share model object between view controllers? -
i created basic os x application storyboard draw circles in custom view. main window contains nssplitviewcontroller
containing 2 sub-views (content , side bar apple pages or numbers have). content view custom subclass of nsview
drawing circles while side bar view contains standard controls. both should bound model object holds properties number of circles, diameter , on.
as understand both subviews have own controllers in case. how have data model object (let's call circles
) both controllers reference can hook key-value observation redrawing custom view on changing controls' values?
my idea create model object in common parent controller , pass on children, how set in interface builder in xcode 7.2?
working off comment. can use representedobject
property of nsviewcontroller pass object along other view controllers. 1 downside though property of type anyobject?
making work swift can awkward. in nsviewcontroller subclass can make new property store data , give correct type, or make protocol define computed property serves wrapper around representedobject
property.
Comments
Post a Comment