• 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
NSArray losing its data
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

NSArray losing its data


  • Subject: NSArray losing its data
  • From: Hasan Diwan <email@hidden>
  • Date: Sun, 17 Nov 2002 02:12:46 -0800

In createNewTransactions, an NSMutableDictionary is added to an
NSMutableArray. By the time, it's saved, all data from the array is
gone. Without further commentary, here's the code, the declaration for
trasactions is in a comment above the createNewTransaction definition:
// NSMutableArray *transactions = [[[NSMutableArray alloc]
initWithCapacity:0] retain];
- (void)createNewTransaction {
NSMutableDictionary *t;
t = [[NSMutableDictionary alloc] init];
[transactions addObject:t];
#ifdef DEBUG
NSLog(@"%@", [transactions lastObject]);
#endif
}

- (IBAction)save:(id)sender {
[[NSSavePanel savePanel] beginSheetForDirectory:[[NSString
stringWithString:@"~/Documents"] stringByExpandingTildeInPath]
file:@".xml"
modalForWindow:[NSApp keyWindow]
modalDelegate:self

didEndSelector:@selector(didEndSaveSheet:returnCode:contextInfo:)
contextInfo:NULL];
}
- (void)didEndSaveSheet:(NSSavePanel *)savePanel
returnCode:(int)returnCode contextInfo:(void *)contextInfo {
[savePanel orderOut:nil];
if (returnCode == NSOKButton) {
NSString *filename = [savePanel filename];
[[NSApp keyWindow] setTitle:filename];
[self updateChangeCount:NSChangeCleared];
#ifdef DEBUG
NSLog(@"%@", [transactions description]);
#endif
if (![transactions writeToFile:filename atomically:YES]) {
NSBeep();
}
}
}
Thanks in advance!
Hasan Diwan
OpenPGP KeyID: 0xBE42DCA6
Fingerprint: 1CB0 47E3 0A24 DAC1 DCCA 4225 F166 40C2 BE42 DCA6
http://www.cs.rpi.edu/~diwanh/gpg.key

[demime 0.98b removed an attachment of type application/pgp-signature which had a name of PGP.sig]
_______________________________________________
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.

  • Prev by Date: how do I disable cell editing in NSTableView?
  • Next by Date: How to show tool tips on a borderless window.
  • Previous by thread: Re: how do I disable cell editing in NSTableView?
  • Next by thread: Re: NSArray losing its data
  • Index(es):
    • Date
    • Thread