Set NSStatusBar titel from other class?

Discussion in 'Mac Programming' started by samirah, Feb 6, 2011.

  1. samirah macrumors newbie

    Jan 31, 2011
    Im trying to change the titel in my NSStatusBar from a different class, my preferences class..

    In my ManagerClass.m & .h i have declared

    - (NSStatusItem *)statusItem
    { return statusItem; }
    I then import my ManagerClass.h in my preferences.m

    then inside preferences.m i try to execute:

    ManagerClass *someInstanceToIt = [[ManagerClass alloc] init];
    [(NSStatusItem *)[someInstanceToIt statusItem] setTitle:@"New Title"];
    But it seems that statusItem is never being passed to the preferences.m file, if i do a test with an if i can see that statusItem is empty..

    Any ideas ? :)
  2. jiminaus macrumors 65816


    Dec 16, 2010
    Where is statusItem in ManagerClass being set?

    Do you really want to alloc/init a new instance of ManagerClass inside a method of Preferences? Or are you rather wanting to reference an already existing instance of ManagerClass created elsewhere?

    What are you type-casting the result of [someInstanceToIt statusItem]? This is unnecessary because statusItem is already declared to return type NSStatusItem *.

Share This Page