PDA

View Full Version : Web Browser In Xcode 4 Help:




dafyddjones2000
Jan 20, 2012, 03:43 PM
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



Red Menace
Jan 20, 2012, 04:28 PM
So, I'm guessing that you haven't read the WebKit Programming Guide (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/DisplayWebContent/DisplayWebContent.html)?

thundersteele
Jan 20, 2012, 05:09 PM
#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.

dafyddjones2000
Jan 23, 2012, 02:01 PM
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

Red Menace
Jan 23, 2012, 02:07 PM
Help us out a little here - which code? how does it fail (error messages, etc)? did your original browser work?

dafyddjones2000
Jan 23, 2012, 02:19 PM
Help us out a little here - which code? how does it fail (error messages, etc)? did your original browser work?

sorry. i am trying to get the textfield to change when i navigate to a new page and this is the 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

@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

----------

sorry. i am trying to get the textfield to change when i navigate to a new page and this is the 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

@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:

//
// 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:

//
// 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];
}
}

Red Menace
Jan 23, 2012, 02:49 PM
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?

dafyddjones2000
Feb 10, 2012, 09:47 AM
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?
Yes i am including the webkit.framework etc

chown33
Feb 10, 2012, 10:25 AM
Yes i am including the webkit.framework etc

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.

dafyddjones2000
Feb 12, 2012, 09:31 AM
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.

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

chown33
Feb 12, 2012, 12:40 PM
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

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.