1. Welcome to the new MacRumors forums. See our announcement and read our FAQ

Web Browser In Xcode 4 Help:

Discussion in 'Mac Programming' started by dafyddjones2000, Jan 20, 2012.

  1. dafyddjones2000, Jan 20, 2012
    Last edited by a moderator: Jan 20, 2012

    macrumors newbie

    #1
    hi.
    i am new to xcode and i have decided to make a web browser for the mac os x, i have coded the back, forward, refresh, stop, url bar, text bigger, text smaller, print.
    i want to know how to make the url bar change when i browse to a new page and how to add a favourites and history center and also if it is possible, make the browser tabbed
    thanks in advance
    dafyddjones2000,

    can i add a home page button to my request please
     
  2. macrumors 6502

    #2
  3. macrumors 68030

    #3
    Code:
    #import <Safari>
    Done!


    Thanks for the link Red Menace. It might help me with one of the projects that I never will really work on due to lack of time.
     
  4. dafyddjones2000, Jan 23, 2012
    Last edited: Jan 23, 2012

    macrumors newbie

    #4
    Re:

    i have now read the documentation but i insert the code and the build fails. also do i type the code in AppDelegate.m or .h?:D
     
  5. macrumors 6502

    #5
    Help us out a little here - which code? how does it fail (error messages, etc)? did your original browser work?
     
  6. macrumors newbie

    #6
    sorry. i am trying to get the textfield to change when i navigate to a new page and this is the code
    Code:
    - (void)webView:(WebView *)sender didStartProvisionalLoadForFrame:(WebFrame *)frame
    {
        // Only report feedback for the main frame.
        if (frame == [sender mainFrame]){
            NSString *url = [[[[frame provisionalDataSource] request] URL] absoluteString];
            [textField setStringValue:url];
        }
    }
    and

    Code:
    @property (assign) IBOutlet WebView *webview;
    which i connected to the webview in IB using assistant editor. the -void ... fails by unknown type 'Webview and 'Expected a type

    ----------

    AppDelegate.h:

    Code:
    //
    //  AppDelegate.h
    //  IcySpike Mac
    //
    //  Created by Dafydd Jones on 17/01/2012.
    //  Copyright (c) 2012 IcySpike. All rights reserved.
    //
    
    #import <Cocoa/Cocoa.h>
    
    
    
    @interface AppDelegate : NSObject <NSApplicationDelegate>
    @property (assign) IBOutlet NSWindow *window;
    @property (assign) IBOutlet WebView *webview;
    AppDelegate.m:

    Code:
    //
    //  AppDelegate.m
    //  IcySpike Mac
    //
    //  Created by Dafydd Jones on 17/01/2012.
    //  Copyright (c) 2012 IcySpike. All rights reserved.
    //
    
    #import "AppDelegate.h"
    
    - (void) webView:(IBOutlet WebView*webview)sender didStartProvisionalLoadForFrame:(WebFrame *)frame;
    
        // Only report feedback for the main frame.
    -if; (frame == [sender mainFrame]){
            NSString *url = [[[[frame provisionalDataSource] request] URL] absoluteString];
            [textField setStringValue:url];
        }
    }
    
     
  7. macrumors 6502

    #7
    If you are getting errors about the web view, are you including the WebKit.framework? You aren't going to get much help if people have to guess. Is textField connected to a text field somewhere? Do you even have a working browser?
     
  8. macrumors newbie

    #8
    Yes i am including the webkit.framework etc
     
  9. macrumors 603

    #9
    Are you importing it?

    The fragments of code you've posted don't show any importing of the Webkit framework. Also, the error message you posted is consistent with failing to import.

    See this thread:
    http://forums.macrumors.com/showthread.php?t=1077607

    Notice he imports Webkit headers. Also notice he posts relatively complete code, rather than isolated lines. We can't see what's wrong with your code if you don't post complete code.


    Are you following a tutorial or book? If so, what is the URL or title, author, and edition?

    If not, what other tutorials or books have you completed?

    At this point, it looks to me like you lack fundamental skills. You won't get very far without them, and learning them within the structure of a tutorial or book is more effective than randomly attempting something just because you want to. For example, if I want to fly a helicopter, I can't just hop in the cockpit and take off. I'll need training and practice first.
     
  10. macrumors newbie

    #10
    yes i have forgotten to import the WebKit but now i need to know how to use an NSSegmented Control segments as separate buttons like in finder
     
  11. macrumors 603

    #11
    Are you following a tutorial or book? If so, what is the URL or title, author, and edition?

    If not, what other tutorials or books have you completed?

    -----

    Steps you should follow to answer your question:

    1. Google search terms: NSSegmentedControl class reference
    (Notice the spelling. There's no space before "Control".)

    2. Click the search result that leads to Apple's class reference document.
    (It's probably the first search result. That was the purpose of including class reference in the search terms.)

    3. On the left side of the class reference doc in the blue sidebar is a COMPANION GUIDE heading. Click the link under that.
    (This is a common pattern in Apple reference docs. The class reference links to a COMPANION GUIDE, and the companion guide links to individual CLASS REFERENCE docs.)

    4. In the companion guide, click the link Segmented Controls Overview. The third paragraph starts "NSSegmentedControl has these features" and follows it with a list. Read the list item "There are three modes...".
    (This tells you what the names of the different modes are, so you can recognize them as you read the rest of the Segmented Controls Programming Guide and the class reference doc. Apple docs are very consistent: when they tell you the name of a mode or feature, it's because they're going to be using that name in the rest of the documentation. So not reading companion guides can leave you not knowing what terms are, and thus unable to find what you're looking for.)

    5. Finish reading the companion guide. Then look up the class reference again and read it. For examples, see the links to Related sample code at the top of the class reference doc.
     

Share This Page