You use the setImage: method, supplying it with an NSImage
which you want to display on the menu bar.
Note also that you can have an NSStatusItem
showing an image and text, for example with the battery indicator.
Here is a small example setting the image to a file named OtherImage.jpg
:
NSImage *statusItemImage = [NSImage imageNamed:@"OtherImage"];
if( !statusItemImage ) {
NSLog(@"ERROR: Could not load the image for 'OtherImage.png'");
} else {
[item setImage:statusItemImage];
}
Make sure that the file OtherImage.png is actually added to your Xcode project and copied into the application's Resources
directory. If your image does not load, it means that the file is not named correctly, not really an image, or not actually in the application bundle.