• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: UnArchiving Mutable Array problem...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: UnArchiving Mutable Array problem...


  • Subject: Re: UnArchiving Mutable Array problem...
  • From: Jerry LeVan <email@hidden>
  • Date: Thu, 22 Jul 2004 17:41:05 -0400

Sigh,

[executedStatements retain];

in the awakeFromNib routine below...

Amazing how fast you can find your mistakes when you
have irrevocably made a fool of yourself.


Jerry
On Jul 22, 2004, at 5:21 PM, Jerry LeVan wrote:

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 unarchiveObjectWithData: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.


References: 
 >UnArchiving Mutable Array problem... (From: Jerry LeVan <email@hidden>)

  • Prev by Date: Re: forcing a dialog to be the active (front) window
  • Next by Date: Re: threads in Xcode
  • Previous by thread: UnArchiving Mutable Array problem...
  • Next by thread: Adding Bindings to NSOutlineView versus a horrible hack
  • Index(es):
    • Date
    • Thread