Re: Saving is so darn hard!
Re: Saving is so darn hard!
- Subject: Re: Saving is so darn hard!
- From: Charles Srstka <email@hidden>
- Date: Sun, 31 Mar 2002 15:17:01 -0600
How about commenting out the stuff that's in +(void)initialize?
On Sunday, March 31, 2002, at 03:00 PM, deekpyro wrote:
Ok, I think I've got most of it, but it still doesn't work:
#import "Controller.h"
NSString *STSCheckBoxKey = @"WBC Enabled";
@implementation Controller
+ (void)initialize
{
// Create a dictionary
NSMutableDictionary *defaultValues = [NSMutableDictionary
dictionary];
// Put the values in the dictionary
[defaultValues setObject:[NSNumber numberWithBool:YES]
forKey:STSCheckBoxKey];
// Register the dictionary of defaults
[[NSUserDefaults standardUserDefaults] registerDefaults:
defaultValues];
NSLog(@"registered default: %@", defaultValues);
}
- (void)windowDidLoad
{
NSUserDefaults *defaults;
defaults = [NSUserDefaults standardUserDefaults];
[theCheckBoxWBC setState:[defaults boolForKey:STSCheckBoxKey]];
}
// actions //
- (IBAction)theCheckBoxWBCClicked:(id)sender
{
[[NSUserDefaults standardUserDefaults] setBool:[sender state]
forKey:
STSCheckBoxKey];
}
What do you think?
on 3/31/02 1:11 PM, Charles Srstka at email@hidden wrote:
Read the documentation for NSUserDefaults and you will soon be saying,
"Saving is so darn easy!"
On Sunday, March 31, 2002, at 11:27 AM, deekpyro wrote:
I want to set up my program so that when it loads whatever the value
of
theCheckBox would be the same as when you closed it (hence it saves).
I've
been refering to multiple books but all of them just confuse me. I
know
about the NSCoding protocal and to use NSArchiver and NSUnarchiver,
but
those are the ones that get me. I know how to do encodeWithCoder and
initWithCoder but those NSArchivers and NSUnarchivers get me. Could
someone
PLEASE show me how to implement those for saving a simple checkBox?
Thanks
so much!
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.