Archiving annotations (was: [Biococoa-dev] Annotation)

Charles PARNOT charles.parnot at
Tue Feb 22 22:48:34 EST 2005

>Another idea:
>how do we write out these things? simple, only accept custom objects that adhere to the <NSCoding> protocol. All objects that aren't natively supported by plist encoding, can be archived into NSData and written as such in the xml. The nice thing is that the datatype (= className) is written in the xml as well, so that makes it easy to unarchive the thing. It needs some logic to control/check but its powerful I think. I can even add a simple - (NSData *)encodedContent; method to the BCAnnotation class which does the work, and can be used by the BSML writer. It can even check whether coding is supported by the custom class and return nil if it does not (in case the object is lost during a write.
>This actually leads me to another question right at the spot, is it a good idea to add a boolean "archive" or something to an annotation? This way you can actively decide whether the annotation should be written out to disk or not (think of temporary attributes, like the one in NSAttributedStrings). For instance, during the life of my program it might be nice to add custom (non-writable) objects to your sequence, but you might not want those be saved with the file (or you're not able to). This way you can specify which are to be saved and which not....

><snip>....and think a bit in the mean time how we would write these away in a file ;-)

This scheme to save objects to disk is perfect. I like the additional BOOL 'shouldArchive'.
I actually also liked the additional fiels 'creator' and 'creationDate' (or something like this?)


Help science go fast forward:

Charles Parnot
charles.parnot at

Room  B157 in Beckman Center
279, Campus Drive
Stanford University
Stanford, CA 94305 (USA)

Tel +1 650 725 7754
Fax +1 650 725 8021

More information about the Biococoa-dev mailing list