• 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: Help with encodeObject: forKey:
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help with encodeObject: forKey:


  • Subject: Re: Help with encodeObject: forKey:
  • From: Ian Gillespie <email@hidden>
  • Date: Tue, 3 Dec 2002 07:54:23 -0800

on 02-12-02 8:28 PM, Ian Gillespie at email@hidden wrote:

Whenever I save, the first line of code in this method gives the
following error:

Exception raised during posting of notification. Ignored. exception:
*** -encodeObject:forKey: only defined for abstract class. Define
-[NSArchiver encodeObject:forKey:]!

Read up on NSArchiver, NSCoder, and archiving in general in the Cocoa
developer documentation. Also read the very long passage on keyed archiving
in the Jaguar Foundation release notes. Also, you'll find a "how-to" article
on keyed archiving at stepwise.com -- look in the Articles index for Recipe
12 of the Vermont Recipes tutorial (or buy my book).

Basically, as your error message says, NSCoder is an abstract class whose
methods are intended to be overridden by concrete subclasses for actual use.
The primary example of a concrete subclass is NSArchiver (or NSKeyedArchiver
for Jaguar and newer), which is what you should be using. You could write
your own concrete subclass, but there isn't much point because the existing
archiving classes cover the basics and then some.

This is a complex subject. And, since keyed archiving is new in Jaguar, it
introduces serious backward compatibility issues of its own -- which are
discussed at length, with suggested strategies, in the release notes (and I
believe recently in the updated developer documentation).

--

Bill Cheeseman - email@hidden
Quechee Software, Quechee, Vermont, USA
http://www.quecheesoftware.com

Thanks Bill,

I solved my problem, to archive my data I was using NSArchiver instead of NSKeyedArchiver. Since my app will only run on 10.2 or higher I figured keyed archiving is the way to go to make modifying my model classes in the future easier.

~Ian
_______________________________________________
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: Re: Default "transparent" background
  • Next by Date: Re: Getting started in Cocoa and IB
  • Previous by thread: Re: Help with encodeObject: forKey:
  • Next by thread: NSToolbars and keyboard navigation
  • Index(es):
    • Date
    • Thread