UnArchiving Mutable Array problem...
UnArchiving Mutable Array problem...
- Subject: UnArchiving Mutable Array problem...
- From: Jerry LeVan <email@hidden>
- Date: Thu, 22 Jul 2004 17:21:33 -0400
Hi,
I am storing "sql" text commands in a mutable array
"executedStatements".
I am trying to "remember" execution history across invocations of my
application. So I thought I could use keyedarchiving to save and restore
my command history.
1) in the header file I have
NSMutableArray *executedStatements;
2) in the controller init method I have
executedStatements = [[NSMutableArray alloc] init];
[executedStatements insertObject:@"FooBar" atIndex:0]; // just to
have something
NSData* historyAsData = [NSKeyedArchiver archivedDataWithRootObject:
executedStatements];
[defaultPrefs setObject:historyAsData forKey:@"BSQLcommandHistory"];
prefs = [[NSUserDefaults standardUserDefaults] retain];
[prefs registerDefaults:defaultPrefs];
[prefs synchronize];
3) in the awake from nib method in the controller I have
// recall the command history
NSLog(@"executedStatements:%@",executedStatements); <-- prints the
expected results
[executedStatements release]; <-- same problem with or without this
NSData *historyAsData = (NSData*)[prefs
objectForKey:@"BSQLcommandHistory"];
executedStatements = (NSMutableArray*)[NSKeyedUnarchiver
unarchiveObjectWith
Data:historyAsData];
NSLog(@"executedStatements:%@",executedStatements); <-- prints the
expected results
The bad news is that I used executedStatements in two other
places...and it appears that
reference to executedStatements *elsewhere* causes a crash (that is
what the debugger is pointing
to in anycase. If I try an NSLog to show the value of
executedStatements I get an exception.
I can't figure out how to show the value of the executedStatements
object in the debugger....
If I don't "unfreeze" executeStatements in the awake from nib routine
the program runs fine
and during the next startup the list of statements will be properly
displayed in step 3) if I
unfreeze executedStatements.
Am I overlooking something obvious?
Jerry
_______________________________________________
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.