Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Switz213

macrumors 6502
Original poster
May 26, 2008
498
0
I want to recreate the Safari menu. I figured out how to make new drop-downs and stuff, but how can I set those to go to a specific site? I have never used IB before, but I am pretty good with coding in general.

Thanks,
Switz
 
Anyone?

For more detail. When you click on a drop down, it drops down, then click on a button and it goes to a website.

Thanks in advance
 
Uhm, IB doesn't write code for you. It makes it easier to link UI elements to your code, but to actually do something you have to write some code to open the URL.

Code:
    BOOL  success;
    NSURL  *moreInfoURL = [[NSURL alloc] initWithString:@"http://www.dhs.gov/dhspublic/"];

    success = [[NSWorkspace sharedWorkspace] openURL:[moreInfoURL absoluteURL]];

That opens a URL. You link that to your menus or whatever, and then it will open a URL when you select it.
 
Thanks,
where would I go about editing that in?

Thanks

in your appController.m file (or where ever) write:

Code:
-(IBAction)thisIsYourURLButtonMethod:(id)sender
{
BOOL  success;
NSURL  *moreInfoURL = [[NSURL alloc] initWithString:@"http://www.dhs.gov/dhspublic/"];

success = [[NSWorkspace sharedWorkspace] openURL:[moreInfoURL absoluteURL]];
[moreInfoURL release];
}

declare the method in appController.h file

then open Interface Builder (or save / build Xcode project if IB is already open so that IB will be in-sync with Xcode), drag a connecting line from your button (that you wanna use to trigger the website) to your appController object, and select "thisIsYourURLButtonMethod"...

easy as pie...
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.