NSKeyedUnarchiverDelegate Protocol Reference

Conforms to
Framework
/System/Library/Frameworks/Foundation.framework
Availability
Available in OS X v10.6 and later.
Companion guide
Declared in
NSKeyedArchiver.h

Overview

The NSKeyedUnarchiverDelegate protocol defines the optional methods implemented by delegates of NSKeyedUnarchiver objects.

Tasks

Decoding Objects

Finishing Decoding

Instance Methods

unarchiver:cannotDecodeObjectOfClassName:originalClasses:

Informs the delegate that the class with a given name is not available during decoding.

- (Class)unarchiver:(NSKeyedUnarchiver *)unarchiver cannotDecodeObjectOfClassName:(NSString *)name originalClasses:(NSArray *)classNames
Parameters
unarchiver

An unarchiver for which the receiver is the delegate.

name

The name of the class of an object unarchiver is trying to decode.

classNames

An array describing the class hierarchy of the encoded object, where the first element is the class name string of the encoded object, the second element is the class name of its immediate superclass, and so on.

Return Value

The class unarchiver should use in place of the class named name.

Discussion

The delegate may, for example, load some code to introduce the class to the runtime and return the class, or substitute a different class object. If the delegate returns nil, unarchiving aborts and the method raises an NSInvalidUnarchiveOperationException.

Availability
  • Available in OS X v10.2 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSKeyedArchiver.h

unarchiver:didDecodeObject:

Informs the delegate that a given object has been decoded.

- (id)unarchiver:(NSKeyedUnarchiver *)unarchiver didDecodeObject:(id)object
Parameters
unarchiver

An unarchiver for which the receiver is the delegate.

object

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

Return Value

The object to use in place of object. The delegate can either return object or return a different object to replace the decoded one. If the delegate returns nil, the decoded value will be unchanged (that is, the original object will be decoded).

Discussion

This method is called after object has been sent initWithCoder: and awakeAfterUsingCoder:.

The delegate may use this method to keep track of the decoded objects.

Availability
  • Available in OS X v10.2 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSKeyedArchiver.h

unarchiver:willReplaceObject:withObject:

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

- (void)unarchiver:(NSKeyedUnarchiver *)unarchiver willReplaceObject:(id)object withObject:(id)newObject
Parameters
unarchiver

An unarchiver for which the receiver is the delegate.

object

An object in the archive.

newObject

The object with which unarchiver will replace object.

Discussion

This method is called even when the delegate itself is doing, or has done, the substitution with unarchiver:didDecodeObject:.

The delegate may use this method if it is keeping track of the encoded or decoded objects.

Availability
  • Available in OS X v10.2 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSKeyedArchiver.h

unarchiverDidFinish:

Notifies the delegate that decoding has finished.

- (void)unarchiverDidFinish:(NSKeyedUnarchiver *)unarchiver
Parameters
unarchiver

An unarchiver for which the receiver is the delegate.

Availability
  • Available in OS X v10.2 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSKeyedArchiver.h

unarchiverWillFinish:

Notifies the delegate that decoding is about to finish.

- (void)unarchiverWillFinish:(NSKeyedUnarchiver *)unarchiver
Parameters
unarchiver

An unarchiver for which the receiver is the delegate.

Availability
  • Available in OS X v10.2 and later.
  • Available as part of an informal protocol prior to OS X v10.6.
Declared In
NSKeyedArchiver.h