Mac Developer Library

Developer

Foundation Framework Reference NSKeyedArchiverDelegate Protocol Reference

Options
Deployment Target:

On This Page
Language:

NSKeyedArchiverDelegate

Inheritance


Not Applicable

Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in OS X v10.6 and later.

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

  • Informs the delegate that a given object has been encoded.

    Declaration

    Swift

    optional func archiver(_ archiver: NSKeyedArchiver, didEncodeObject object: AnyObject?)

    Objective-C

    - (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).

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.2 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Notifies the delegate that encoding has finished.

    Declaration

    Swift

    optional func archiverDidFinish(_ archiver: NSKeyedArchiver)

    Objective-C

    - (void)archiverDidFinish:(NSKeyedArchiver *)archiver

    Parameters

    archiver

    The archiver that sent the message.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.2 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Informs the delegate that object is about to be encoded.

    Declaration

    Swift

    optional func archiver(_ archiver: NSKeyedArchiver, willEncodeObject object: AnyObject) -> AnyObject?

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.2 and later.

    Available as part of an informal protocol prior to OS X v10.6.

  • Notifies the delegate that encoding is about to finish.

    Declaration

    Swift

    optional func archiverWillFinish(_ archiver: NSKeyedArchiver)

    Objective-C

    - (void)archiverWillFinish:(NSKeyedArchiver *)archiver

    Parameters

    archiver

    The archiver that sent the message.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.2 and later.

    Available as part of an informal protocol prior to OS X v10.6.

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

    Declaration

    Swift

    optional func archiver(_ archiver: NSKeyedArchiver, willReplaceObject object: AnyObject, withObject newObject: AnyObject)

    Objective-C

    - (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.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in OS X v10.2 and later.

    Available as part of an informal protocol prior to OS X v10.6.