// BWSnippetKeeper -- container object that keeps track of HTML fragments.
//		      Individual values accessed by KVC because I'm lazy

// Copyright (C) 2005 Borkware, LLC
// We use the BSD License.  Check out http://borkware.com/license

#import "BWSnippetKeeper.h"


@implementation BWSnippetKeeper


// bottleneck to get the string for a key from the defaults

- (NSString *) stringFromDefaultsFor: (NSString *) key
{
    NSString *value;
    value = [[NSUserDefaults standardUserDefaults] stringForKey: key];

    return (value);

} // stringFromDefaultsFor



// bottleneck to set a string for a key into the defaults

- (void) setString: (NSString *) value  
     inDefaultsFor: (NSString *) key
{
    [[NSUserDefaults standardUserDefaults] 
        setObject: value
        forKey: key];

} // setStringInDefaults




// accept the changes and store them into the user defaults



// KVC magic.  They can do a valueForKey: for a snippet.  Rather than
// providing an API for everything, just use this to get the values.

- (id) valueForUndefinedKey: (NSString *) key
{
    id value;
    value = [self stringFromDefaultsFor: key];

    if (value == nil) {
        value = [super valueForUndefinedKey: key];
    }
    
    return (value);
    
} // valueForUndefinedKey


@end // BWSnippetKeeper

