xcode web browser help

Discussion in 'Mac Programming' started by subrodrigh, Dec 19, 2008.

  1. subrodrigh macrumors newbie

    Dec 19, 2008
    I am programming a simple browser in xcode, there is no URL box or buttons, a simple application that would when launched would load up a specified URL that i chose. Kinda like the iTunes store, you can't see it and cant right click on anything.

    But the problem is i have put the safari app in the window, and disabled resizing, but i cannot think how to specify a default URL.

    My first time using xcode and its brill, o easy to use but just can't think of this one lol. I don't have any knowledge of coding so please help.

    Thanks for your help everyone.
  2. kainjow Moderator emeritus


    Jun 15, 2000
    Don't mix up Xcode and Interface Builder. IB is for creating a UI. Xcode is where you actually write the code. If IB doesn't have an option for setting the default URL then you'd have to write some code. If you don't know how to write code then I suppose it's time to learn :)
  3. subrodrigh thread starter macrumors newbie

    Dec 19, 2008

    Accident's Happen, as i explained i have just started using xcode.

    Thanks for the advice anyway but it was just a simple question looking for a guide as to how i would do it.
  4. kainjow Moderator emeritus


    Jun 15, 2000
    Not an accident, just clarifying the terminology. If you know the terminology, than you can research and ask questions better :)

    What exactly are your intentions? Are you wanting to learn programming or just messing around?
  5. plinden macrumors 68040


    Apr 8, 2004
    If I'm not misremembering (I'm not at home so can't check), Hillegass's XCode book (Amazon), (Bookpool) has a sample program (among other useful examples) that uses an embedded browser window.

    I recommend that book if you want to learn Cocoa/XCode/Interface Builder.

    Like kainjow said, you'll need to add some code to be able to specify a default URL.
  6. subrodrigh thread starter macrumors newbie

    Dec 19, 2008

    All i am really wanting to do is have a program that people could download from my website that they can open and have a specific page open,
    its a music section of my site, i am a total Xcode and IB newbie,
    i have been looking on a couple video's on youtube and thats where i got the idea for this.

    Just a simple application that you can open and a web page is brought up.

    I have the application working fine just now but just don't know how to specify a URL to load up when the application is launched.
    I have tried a couple of the help documents suggestions but i am totally confused.

    I was just hoping someone might be able to explain what i should do and where to put the code ??

  7. baka rakuda macrumors newbie

    Dec 21, 2008
    You should checkout the "Webkit Objective-C Programming Guide" in the Xcode documentation.

    Specifically the Simple Browser page.

    Basically all you need to do is add this code in whatever class file you are loading your web view:

    //create the link to our site
    NSString *bakaLink = @"http://blog.bakarakuda.com";
    //myWebView is the instance of our WebView class
    [[myWebView mainFrame] 
          requestWithURL:[NSURL URLWithString:bakaLink]]];
    That should do it.

    I just setup a quick project in about a minute and got this to work, All I have is an AppController class and I've placed this code in the awakeFromNib method.

Share This Page