Sign In/My Account | View Cart  

advertisement

AddThis Social Bookmark Button

Article:
  BYOB: Build Your Own Browser, Part 2
Subject:   small correction
Date:   2004-05-29 12:27:11
From:   zeus
The prototype for the:
(void)setDefaultHomepage:(NSString*)homepage{}
should be:
-(void)setDefaultHomepage:(NSString*)homepage;
and not:
(void)setDefaultHomepage:(NSString*);


BTW very nice article.


CU

Full Threads Oldest First

Showing messages 1 through 2 of 2.

  • re:small correction
    2004-05-29 17:54:49  Andrew Anderson | [View]

    good catch. thanks!!
    • re:small correction
      2005-03-08 17:14:35  -JR- [View]

      I am having a problem with your tutorial here...(you should explain the second page a bit clearer) Heres my myDocument code, and i only assumed that all the code should go in there.. Would be nice with a reply, I am getting only three errors, but i cannot run the app; What is wrong and what more do you need to see? Thanx jR.

      Code:
      //
      // MyDocument.m
      // MMapp
      //
      // Created by JR on 09.03.05.
      // Copyright __M & M__ 2005 . All rights reserved.
      //
      #import "MyDocument.h"
      static NSString *defaultHP =@"file:///Users/jr/Desktop/flash/pageflip_v211.html";
      @implementation MyDocument

      - (id)init
      {
      self = [super init];
      if (self) {

      // Add your subclass-specific initialization here.
      // If an error occurs here, send a [self release] message and return nil.

      }
      return self;
      }

      - (NSString *)windowNibName
      {
      // Override returning the nib file name of the document
      // If you need to use a subclass of NSWindowController or if your document supports multiple NSWindowControllers, you should remove this method and override -makeWindowControllers instead.
      return @"MyDocument";
      }

      - (void)windowControllerDidLoadNib:(NSWindowController *) aController
      {
      [super windowControllerDidLoadNib:aController];
      // Add any code here that needs to be executed once the windowController has loaded the document's window.
      [urlString setStringValue:defaultHP];
      [[webView mainFrame] loadRequest:
      [NSURLRequest requestWithURL:
      [NSURL URLWithString:defaultHP]]];
      [webView setUIDelegate:self];
      [webView setGroupName:@"MyDocument"];
      [webView setFrameLoadDelegate:self];

      }

      - (NSData *)dataRepresentationOfType:(NSString *)aType
      {
      // Insert code here to write your document from the given data. You can also choose to override -fileWrapperRepresentationOfType: or -writeToFile:ofType: instead.
      return nil;
      }

      - (BOOL)loadDataRepresentation:(NSData *)data ofType:(NSString *)aType
      {
      // Insert code here to read your document from the given data. You can also choose to override -loadFileWrapperRepresentation:ofType: or -readFromFile:ofType: instead.
      return YES;
      }

      - (IBAction)connectURL:(id)sender{
      [urlString setStringValue:[sender stringValue]];
      [[webView mainFrame] loadRequest:
      [NSURLRequest requestWithURL:
      [NSURL URLWithString:
      [sender stringValue]]]];
      }

      - (id)webView
      {
      return webView;
      }
      - (WebView *)webView:(WebView *)sender
      createWebViewWithRequest:
      (NSURLRequest *)request
      {
      id myDocument = [
      [NSDocumentController
      sharedDocumentController]
      openUntitledDocumentOfType:
      @"DocumentType"
      display:YES];

      [[[myDocument webView] mainFrame]
      loadRequest:request];

      return [myDocument webView];
      }

      - (void)webViewShow:(WebView *)sender
      {
      id myDocument = [[NSDocumentController
      sharedDocumentController]
      documentForWindow:
      [sender window]];
      [myDocument showWindows];
      }
      - (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];

      [urlString setStringValue:url];
      }

      -(void)setDefaultHomepage:(NSString*)homepage{
      defaultHP = homepage;
      }
      -(NSString *)getDefaultHomepage{
      return defaultHP;
      }

      @end