osx - NSMenu initializer or didLoad equivalent? -


i'm trying build menubar application on os x nsmenu being shown when menubar icon clicked having custom amount of nsmenuitems. amount specified in settings window , thought best way of carrying number on save nsuserdefaults , sending nsnotificationcenter notification when value has changed, controller in charge of setting , holding data nsmenu can load value defaults when notification received.

the problem i'm experiencing here though i'm unsure how tell menu controller subscribe notifications. since subclassed nsmenu don't have initializer can done. or equivalent didload method nswindowcontrollers have.

another option maybe have menu controller singleton , speak directly without going through notification center. or have reference in app delegate amount same thing here.

or maybe i'm overthinking entirely , there's easier way of working this?

thanks , tips!

of course nsmenu has initializer. classes do.

probably, instantiated menu in nib. in case, loading nib initialize menu calling -initwithcoder:, nsmenu implements part of adopting nscoding protocol.

if you're instantiating menu in code, must calling initializer part of (you call [[nsmenu alloc] init...], init... specific initializer).

your scheme notifications should work fine.

you have app controller mediate between settings window , menu. have outlet menu call appropriate methods, including ones added subclass.


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -