• 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
Reading Archived Data From File
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Reading Archived Data From File


  • Subject: Reading Archived Data From File
  • From: "Frederick C. Lee" <email@hidden>
  • Date: Tue, 8 Jun 2004 16:02:46 -0700

Greetings:

Scenario: My NSMutableDictionary is composed of {CountryName Key/
CountryModel objects}. The CountryModel is a custom class that
contains assorted instance variables including a NSMutableDictionary of
CityModels.

I'm trying to read/write theCountryMDict (NSMutableDictionary of
countries) to/from disk.


--------------------------------
1) Writing 'theCountryMDict ' appears to work (saved 242+ countries):

#pragma mark WRITING TO DISK
- (IBAction)saveDataToDisk:(id)sender {

if (![NSKeyedArchiver archiveRootObject:theCountryMDict
toFile:countryDataSource]) { // Good
NSLog(@"{saveDataToDisk} Sorry, the archiving failed.");
}
}


2) However, Reading the same archived data from disk fails:
//
------------------------------------------------------------------------
---------

#pragma mark READING FROM DISK
- (IBAction)readDataFromDisk:(id)sender {
theCountryMDict = [[NSUnarchiver
unarchiveObjectWithFile:countryDataSource] retain]; // Fails to
populate theCountryMDict.

}

========================================================================
===========

3) I get the following error:

*** +[NSUnarchiver unarchiveObjectWithData:]: extra data discarded


4) I did a [theCountryMDict count] and got zero (0):

ricCountries[915] {testAction} theCountryMDict count= 0

=================

5) Question: How can I successfully restore 'theCountryMDict' from
disk? What's wrong with using NSUnarchiver via #2) above?

Thanks in advance!

Regards,

Ric.
_______________________________________________
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.


  • Follow-Ups:
    • Re: Reading Archived Data From File
      • From: Nick Zitzmann <email@hidden>
    • Re: Reading Archived Data From File
      • From: "Mark A. Stratman" <email@hidden>
  • Prev by Date: Problem with DEBUG symbol in Debugging.h after XCode upgrade
  • Next by Date: Re: Why is the list so slow?
  • Previous by thread: Problem with DEBUG symbol in Debugging.h after XCode upgrade
  • Next by thread: Re: Reading Archived Data From File
  • Index(es):
    • Date
    • Thread