NSKeyedArchiverDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in iOS 4.0 and later.
Companion guide
Declared in
NSKeyedArchiver.h

Overview

The NSKeyedArchiverDelegate protocol defines the optional methods implemented by delegates of NSKeyedArchiver objects.

Tasks

Encoding Data and Objects

Instance Methods

archiver:didEncodeObject:

Informs the delegate that a given object has been encoded.

- (void)archiver:(NSKeyedArchiver *)archiver didEncodeObject:(id)object
Parameters
archiver

The archiver that sent the message.

object

The object that has been encoded. object may be nil.

Discussion

The delegate might restore some state it had modified previously, or use this opportunity to keep track of the objects that are encoded.

This method is not called for conditional objects until they are actually encoded (if ever).

Availability
  • Available in iOS 2.0 and later.
  • Available as part of an informal protocol prior to iOS 4.0.
Declared In
NSKeyedArchiver.h

archiver:willEncodeObject:

Informs the delegate that object is about to be encoded.

- (id)archiver:(NSKeyedArchiver *)archiver willEncodeObject:(id)object
Parameters
archiver

The archiver that sent the message.

object

The object that is about to be encoded. This value is never nil.

Return Value

Either object or a different object to be encoded in its stead. The delegate can also modify the coder state. If the delegate returns nil, nil is encoded.

Discussion

This method is called after the original object may have replaced itself with replacementObjectForKeyedArchiver::.

This method is called whether or not the object is being encoded conditionally.

This method is not called for an object once a replacement mapping has been set up for that object (either explicitly, or because the object has previously been encoded). This method is also not called when nil is about to be encoded.

Availability
  • Available in iOS 2.0 and later.
  • Available as part of an informal protocol prior to iOS 4.0.
Declared In
NSKeyedArchiver.h

archiver:willReplaceObject:withObject:

Informs the delegate that one given object is being substituted for another given object.

- (void)archiver:(NSKeyedArchiver *)archiver willReplaceObject:(id)object withObject:(id)newObject
Parameters
archiver

The archiver that sent the message.

object

The object being replaced in the archive.

newObject

The object replacing object in the archive.

Discussion

This method is called even when the delegate itself is doing, or has done, the substitution. The delegate may use this method if it is keeping track of the encoded or decoded objects.

Availability
  • Available in iOS 2.0 and later.
  • Available as part of an informal protocol prior to iOS 4.0.
Declared In
NSKeyedArchiver.h

archiverDidFinish:

Notifies the delegate that encoding has finished.

- (void)archiverDidFinish:(NSKeyedArchiver *)archiver
Parameters
archiver

The archiver that sent the message.

Availability
  • Available in iOS 2.0 and later.
  • Available as part of an informal protocol prior to iOS 4.0.
Declared In
NSKeyedArchiver.h

archiverWillFinish:

Notifies the delegate that encoding is about to finish.

- (void)archiverWillFinish:(NSKeyedArchiver *)archiver
Parameters
archiver

The archiver that sent the message.

Availability
  • Available in iOS 2.0 and later.
  • Available as part of an informal protocol prior to iOS 4.0.
Declared In
NSKeyedArchiver.h