advertisement

Article:
  BYOB: Build Your Own Browser, Part 3
Subject:   6 Warnings and 4 Errors prevent Compiling
Date:   2005-02-28 13:35:33
From:   ratpack
I am brand new to Cocoa and objective-C, but I'm pretty strong with PHP, JavaScript and the like.


Anyway.. I've gone through part 3 of BYOB several times from beginning to end. I started by typing everything myself at least 3 times. Convinced I was an idiot and had been making typo after typo, I copied and pasted the code from the tutorial into my project.


I keep getting the same 6 warning (4 if I remove the ignorecontent bits) and 4 errors and can't figure out what I've done wrong.


Any help would be greatly appreciated.


The warnings/errors I get are:
Cannot find method `-setIgnoreContent:'; return type `id` assumed


`MyDocument` may not respond to `-setIgnoreContent:`


cannot find method `-getDefaultHomepage`; return type `id` assumed


`MyDocument may not respond to `-getDefaultHomeage`


cannot find method `-getIgnoreContent'; return type `id' assumed


`MyDocument' may not respond to `-getIgnoreContent'


error: `autoloadImages' undeclared (first use in this function ) (Each undeclared identifier is reported only once for each function it appears in.)


error: `javascriptEnabled' undeclared (first use in this function)


error: `autoloadImages' undeclared (first use in this function)


error: `javascriptEnabled' undeclared (first use in this function)



I realize that these are stating that I have an undeclared function somewhere, but I can't find it and I can't find reference to declaring this function in the tutorial.


I don't see anybody else with a mention of this type of problem, so I'm back to assuming my own idiocy has caused this issue.


Below is my Controller.h file


/* Controller */


#import <Cocoa/Cocoa.h>
#import <WebKit/WebPreferences.h>
#import <WebKit/WebView.h>


#import "MyDocument.h"


@interface Controller : NSObject
{
IBOutlet id allowAnimatedImages;
IBOutlet id autoLoadImages;
IBOutlet id defaultHomepage;
IBOutlet id javaScriptEnabled;
IBOutlet id ignoreContent;

WebPreferences *p;
MyDocument *md;
}
- (IBAction)apply:(id)sender;




@end



and here is my Controller.m file:



#import "Controller.h"


@implementation Controller



- (void)awakeFromNib
{
md = [MyDocument alloc];
[md init];

WebView *wv = [WebView alloc];
[wv init];
[wv setPreferencesIdentifier:@"jomplomp"];

p = [wv preferences];
[p setAutosaves:YES];

NSUserDefaults *defaults;
defaults = [NSUserDefaults standardUserDefaults];
NSString * dHomepage = [defaults stringForKey:@"defaultHomepage"];
if (dHomepage != nil) {
[md setDefaultHomepage:dHomepage];

}

}


- (IBAction)apply:(id)sender
{
NSUserDefaults *defaults;
defaults = [NSUserDefaults standardUserDefaults];

NSString* dHomepage = [defaultHomepage stringValue];
[defaults setObject:dHomepage forKey:@"defaultHomepage"];
[md setDefaultHomepage:dHomepage];



[p setAutosaves:YES];

if ([autoloadImages state] == NSOffState){
[p setLoadsImagesAutomatically:NO];
}
else {
[p setLoadsImagesAutomatically:YES];
}

if ([allowAnimatedImages state] == NSOffState){
[p setAllowsAnimatedImageLooping:NO];
}
else {
[p setAllowsAnimatedImageLooping:YES];
}

if ([javascriptEnabled state] == NSOffState){
[p setJavaScriptEnabled:NO];
}
else {
[p setJavaScriptEnabled:YES];
}

NSString* iContent = [ignoreContent stringValue];
[defaults setObject:iContent forKey:@"ignoreContent"];
[md setIgnoreContent:iContent];
}



- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
[defaultHomepage setStringValue:[md getDefaultHomepage]];
[ignoreContent setStringValue:[md getIgnoreContent]];

[p setAutosaves:YES];

if ([p loadsImagesAutomatically]){
[autoloadImages setState:NSOnState];
}
else {
[autoloadImages setState:NSOffState];
}

if ([p allowsAnimatedImageLooping]){
[allowAnimatedImages setState:NSOnState];
}
else {
[allowAnimatedImages setState:NSOffState];
}

if ([p isJavaScriptEnabled]){
[javascriptEnabled setState:NSOnState];
}
else {
[javascriptEnabled setState:NSOffState];
}
}


@end



As I said, any help would be appreciated as I'm new to Objective-C and cocoa.


Thank you.


BTW: I think the tutorials up to this point have been great! They helped me quickly understand something up to a point that was total greek to me prior to your series.




1 to 1 of 1
  1. 6 Warnings and 4 Errors prevent Compiling
    2005-05-22 20:07:39  Danys [View]

1 to 1 of 1