|
I've gone over the code and tutorial multple times.
I seem to be having the same issue as an earlier poster. Default homepage saves but the rest of the preferences don't. I have quadruple checked all the actions and outlets and ib relationships. I have removed all ignorecontent code but atlas can't get autoload images to save or javascript. if I reverse the yes and the NO here then atleast images load.:
if ([autoloadImages state] == NSOffState){
[p setLoadsImagesAutomatically:NO];
}
else {
[p setLoadsImagesAutomatically:YES];
}
any help would be greatly appreciated
here is all the code for controller.m:
#import "Controller.h"
#import <WebKit/WebPreferences.h>
@implementation Controller
- (void)awakeFromNib
{
md = [MyDocument alloc];
[md init];
WebView *wv = [WebView alloc];
[wv init];
[wv setPreferencesIdentifier:@"PREF"];
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];
}
}
- (void)windowDidBecomeKey:(NSNotification *)aNotification
{
[defaultHomepage setStringValue:[md getDefaultHomepage]];
[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
here is the code for controller.h:
/* 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;
WebPreferences *p;
MyDocument *md;
}
- (IBAction)apply:(id)sender;
@end
|