I am having an issue where I am saving, among other things, an array of "nodes" (header below) that posses a color and a tag property. When it saves as in - (void)saveDataToDiskWithPath:(NSURL*)path, the log shows that these properties exist. When I load the array again at a later time from the saved file, the frame of the node persists, but each node in the array has lost its tag and color...any ideas why? What could I be doing wrong? Maybe I'm just tired, and it will all make sense later...
Node.h:
//
// Node.h
//
#import <Cocoa/Cocoa.h>
@interface Node : NSView {
@private
NSColor *thisColor;
NSColor *originalColor;
NSRect dragRect;
BOOL msDn;
long tag;
BOOL amSelected;
}
@property long tag;
@property (nonatomic, retain) NSColor* originalColor;
- (id)initWithFrame:(NSRect)frame andColor:(NSColor*)color;
- (void)select:(BOOL)yesOrNo;
@end
The save method:
- (void) saveDataToDiskWithPath:(NSURL*)path
{
NSLog(@"Path is %@", [path absoluteString]);
NSMutableDictionary * rootObject;
rootObject = [NSMutableDictionary dictionary];
for(Node* node in [sharedValues nodes]){
NSLog(@"Node has color %@ and tag %ld.", [node originalColor], [node tag]);
}
[rootObject setValue: [imageView aPath] forKey:@"path"];
[rootObject setValue:[sharedValues nodes] forKey:@"nodes"];
[NSKeyedArchiver archiveRootObject: rootObject toFile: [path path]];
}
The load method:
- (void)loadDataFromDiskWithPath:(NSURL*)path
{
NSDictionary * rootObject;
rootObject = [NSKeyedUnarchiver unarchiveObjectWithFile:[path path]];
[imageView setAPath:[rootObject valueForKey:@"path"]];
[sharedValues setNodes:[rootObject valueForKey:@"nodes"]];
[imageView setNeedsDisplay:YES];
}