xcode - How to share model object between view controllers? -


i created basic os x application storyboard draw circles in custom view. main window contains nssplitviewcontrollercontaining 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

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

android - Keyboard hides my half of edit-text and button below it even in scroll view -