DekGenius.com
[ Team LiB ] Previous Section Next Section

NSKeyedArchiver Mac OS X 10.2

This class is a concrete subclass of NSCoder that encodes objects and scalar values into a data format that can be stored in a file. NSKeyedArchiver is different from NSArchiver in that each object and scalar in the archive has an associated name or key. These keys make it possible to decode the archive piecemeal; that is, in an order that is different from the original encoding. Clients have the option of picking and choosing which objects to decode. Non-keyed archives suffer from the limitation that the entirety of an archive must be decoded at once, and in the order that it was encoded. Archiving is described in greater detail in Chapter 2.

figs/cocn_1346.gif

@interface NSKeyedArchiver : NSCoder
 // Initializers
   - (id)initForWritingWithMutableData:(NSMutableData *)data;
 // Accessor Methods
   - (void)setDelegate:(id)delegate;
   - (id)delegate;
   - (void)setOutputFormat:(NSPropertyListFormat)format;
   - (NSPropertyListFormat)outputFormat;
   - (void)setClassName:(NSString *)codedName forClass:(Class)cls;
 // Class Methods
   + (BOOL)archiveRootObject:(id)rootObject toFile:(NSString *)path;
   + (NSData *)archivedDataWithRootObject:(id)rootObject;
   + (NSString *)classNameForClass:(Class)cls;
   + (void)setClassName:(NSString *)codedName forClass:(Class)cls;
 // Instance Methods
   - (void)encodeConditionalObject:(id)objv forKey:(NSString *)key;
   - (void)encodeBool:(BOOL)boolv forKey:(NSString *)key;
   - (void)encodeBytes:(const uint8_t *)bytesp length:(unsigned)lenv forKey:(NSString *)key;
   - (void)encodeDouble:(double)realv forKey:(NSString *)key;
   - (void)encodeFloat:(float)realv forKey:(NSString *)key;
   - (void)encodeInt32:(int32_t)intv forKey:(NSString *)key;
   - (void)encodeInt64:(int64_t)intv forKey:(NSString *)key;
   - (void)encodeInt:(int)intv forKey:(NSString *)key;
   - (NSString *)classNameForClass:(Class)cls;
   - (void)encodeObject:(id)objv forKey:(NSString *)key;
   - (void)finishEncoding;
// Methods Implemented by the Delegate
   - (void)archiver:(NSKeyedArchiver *)archiver didEncodeObject:(id)object;
   - (id)archiver:(NSKeyedArchiver *)archiver  willEncodeObject:(id)object;
   - (void)archiver:(NSKeyedArchiver *)archiver willReplaceObject:(id)object withObject:(id)newObject;
   - (void)archiverDidFinish:(NSKeyedArchiver *)archiver;
   - (void)archiverWillFinish:(NSKeyedArchiver *)archiver;

    [ Team LiB ] Previous Section Next Section