Hello everyone,
I’m looking for some guidance on how to proceed, as this item I’m trying to work on is really driving me nuts.
I had posted a while ago about trying to make a menulet that would show the local IP address of the computer. I’m going to be deploying this to ~1200 computers to help with our tech support needs via ard/vnc. We’ve found that most of our employees cannot be bothered to find their IP address, so we want to have it displayed in an easy-to-find area.
So a while ago I started to follow some tutorials (http://www.mactech.com/articles/mactech/Vol.22/22.02/Menulet/) on how to make a menulet. I am by no means an ObjC user, but I know enough to follow along. I was able to get the example working with no problems under 10.4 and 10.5.
Now i’m working on a 10.6 machine running XCode 3.2.1 and I cannot get these examples to work at all. I was able to get it to set the status item, but I cannot get it to fire off the code that will actually check and do an update. I eventually want to make it with no user interaction and I’m going to wrap some command line code to pull the currently active card’s address, but I can’t even get it to pull the “test” string I have right now.
I guess what I’m trying to figure out now is, is it worth it to try and continue with this menulet ( and can I make it so that it will run on 10.4, 10.5 and 10.6 with the same code) or should I be looking to a different solution? Our windows guy has the ability to either embed the IP address on the desktop or make it a tool tip when hovering over the main hard drive, but I’m not sure if that’s something that is even possible.
If someone can help me out with the code for the menulet, that would be great, but any advice would be welcome. I want to learn more about apple programming, but, of course, I was thrown into this by my boss so I have to make it first and understand it later, so I apologize for my newbie-ness with all of this.
IPMenulet.h
[code]#import <Cocoa/Cocoa.h>
@interface IPMenulet : NSObject {
NSStatusItem *statusItem;
}
-(IBAction)updateIpAddress:(id)sender;
@end[/code]
IPMenulet.m
[code]#import “IPMenulet.h”
@implementation IPMenulet
-
(void) awakeFromNib{
//Create the NSStatusBar and set its length
statusItem = [[[NSStatusBar systemStatusBar] statusItemWithLength:NSVariableStatusItemLength] retain];[statusItem setHighlightMode:NO];
[statusItem setTitle:[NSString
stringWithString:@“Updating…”]];
[statusItem setEnabled:YES];
[statusItem setToolTip:@“Your Current IP Address”];
} -
(void) dealloc {
[statusItem release];
[super dealloc];
}
-(IBAction)updateIpAddress:(id)sender
{
[statusItem setTitle:
[NSString stringWithString:@“test”]];
}
@end[/code]
Thanks for any help anyone can give.