Question

How can I update my statusItem Title? At the moment I do it with a timer

[NSTimer scheduledTimerWithTimeInterval:0.01 target:self selector:@selector(myVoid) userInfo:nil repeats:YES];

and the void is:

-(void)myVoid {

statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];
[statusItem setTitle:myString];

}

The content of myString changes. How can I update the Title? At the moment, when I update it there comes another statusItem and another and another...

Was it helpful?

Solution

Create the statusItem once and keep a reference to it in an ivar, then setTitle on that rather than creating a new statusItem each time (statusItemWithLength: creates a new item).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top