iOS Developer Library

Developer

Foundation Framework Reference NSCoder Class Reference

Options
Deployment Target:

On This Page
Language:

NSCoder

Conforms To


Import Statement


Swift

import Foundation

Objective-C

@import Foundation;

Availability


Available in iOS 2.0 and later.

The NSCoder abstract class declares the interface used by concrete subclasses to transfer objects and other values between memory and some other format. This capability provides the basis for archiving (where objects and data items are stored on disk) and distribution (where objects and data items are copied between different processes or threads). The concrete subclasses provided by Foundation for these purposes are NSArchiver, NSUnarchiver, NSKeyedArchiver, NSKeyedUnarchiver, and NSPortCoder. Concrete subclasses of NSCoder are referred to in general as coder classes, and instances of these classes as coder objects (or simply coders). A coder object that can only encode values is referred to as an encoder object, and one that can only decode values as a decoder object.

NSCoder operates on objects, scalars, C arrays, structures, and strings, and on pointers to these types. It does not handle types whose implementation varies across platforms, such as union, void *, function pointers, and long chains of pointers. A coder object stores object type information along with the data, so an object decoded from a stream of bytes is normally of the same class as the object that was originally encoded into the stream. An object can change its class when encoded, however; this is described in Archives and Serializations Programming Guide.

The AV Foundation framework adds methods to the NSCoder class to make it easier to create archives including Core Media time structures, and extract Core Media time structure from archives.

Subclassing Notes

For details of how to create a subclass of NSCoder, see Subclassing NSCoder in Archives and Serializations Programming Guide.

  • A Boolean value that indicates whether the receiver supports keyed coding of objects. (read-only)

    Declaration

    Swift

    var allowsKeyedCoding: Bool { get }

    Objective-C

    @property(readonly) BOOL allowsKeyedCoding

    Discussion

    NOfalse by default. Concrete subclasses that support keyed coding, such as NSKeyedArchiver, need to override this property to return YEStrue.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Returns a Boolean value that indicates whether an encoded value is available for a string.

    Declaration

    Swift

    func containsValueForKey(_ key: String) -> Bool

    Objective-C

    - (BOOL)containsValueForKey:(NSString *)key

    Discussion

    Subclasses must override this method if they perform keyed coding.

    The string is passed as key.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Encodes a point and associates it with the specified key in the receiver’s archive.

    Declaration

    Swift

    func encodeCGPoint(_ point: CGPoint, forKey key: String!)

    Objective-C

    - (void)encodeCGPoint:(CGPoint)point forKey:(NSString *)key

    Parameters

    point

    The point to encode.

    key

    The key identifying the data.

    Discussion

    When decoding the data from the archive, you pass the value in the key parameter to the corresponding decodeCGPointForKey: method to retrieve the data.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Encodes a rectangle and associates it with the specified key in the receiver’s archive.

    Declaration

    Swift

    func encodeCGRect(_ rect: CGRect, forKey key: String!)

    Objective-C

    - (void)encodeCGRect:(CGRect)rect forKey:(NSString *)key

    Parameters

    rect

    The rectangle to encode.

    key

    The key identifying the data.

    Discussion

    When decoding the data from the archive, you pass the value in the key parameter to the corresponding decodeCGRectForKey: method to retrieve the data.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Encodes size information and associates it with the specified key in the receiver’s archive.

    Declaration

    Swift

    func encodeCGSize(_ size: CGSize, forKey key: String!)

    Objective-C

    - (void)encodeCGSize:(CGSize)size forKey:(NSString *)key

    Parameters

    size

    The size information to encode.

    key

    The key identifying the data.

    Discussion

    When decoding the data from the archive, you pass the value in the key parameter to the corresponding decodeCGSizeForKey: method to retrieve the data.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Encodes an affine transform and associates it with the specified key in the receiver’s archive.

    Declaration

    Swift

    func encodeCGAffineTransform(_ transform: CGAffineTransform, forKey key: String!)

    Objective-C

    - (void)encodeCGAffineTransform:(CGAffineTransform)transform forKey:(NSString *)key

    Parameters

    transform

    The transform information to encode.

    key

    The key identifying the data.

    Discussion

    When decoding the data from the archive, you pass the value in the key parameter to the corresponding decodeCGAffineTransformForKey: method to retrieve the data.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Encodes edge inset data and associates it with the specified key in the receiver’s archive.

    Declaration

    Swift

    func encodeUIEdgeInsets(_ insets: UIEdgeInsets, forKey key: String!)

    Objective-C

    - (void)encodeUIEdgeInsets:(UIEdgeInsets)insets forKey:(NSString *)key

    Parameters

    insets

    The edge insets data to encode.

    key

    The key identifying the data.

    Discussion

    When decoding the data from the archive, you pass the value in the key parameter to the corresponding decodeUIEdgeInsetsForKey: method to retrieve the data.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Encodes offset data and associates it with the specified key in the receiver’s archive.

    Declaration

    Swift

    func encodeUIOffset(_ offset: UIOffset, forKey key: String!)

    Objective-C

    - (void)encodeUIOffset:(UIOffset)offset forKey:(NSString *)key

    Parameters

    offset

    The offset data to encode.

    key

    The key identifying the data.

    Discussion

    When decoding the data from the archive, you pass the value in the key parameter to the corresponding decodeUIOffsetForKey: method to retrieve the data.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Encodes a given CMTime structure and associates it with a specified key.

    Declaration

    Swift

    func encodeCMTime(_ time: CMTime, forKey key: String!)

    Objective-C

    - (void)encodeCMTime:(CMTime)time forKey:(NSString *)key

    Parameters

    time

    A CMTime structure.

    key

    The key with which to associate time in the archive.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Encodes a given CMTimeRange structure and associates it with a specified key.

    Declaration

    Swift

    func encodeCMTimeRange(_ timeRange: CMTimeRange, forKey key: String!)

    Objective-C

    - (void)encodeCMTimeRange:(CMTimeRange)timeRange forKey:(NSString *)key

    Parameters

    timeRange

    A CMTimeRange structure.

    key

    The key with which to associate timeRange in the archive.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Encodes a given CMTimeMapping structure and associates it with a specified key.

    Declaration

    Swift

    func encodeCMTimeMapping(_ timeMapping: CMTimeMapping, forKey key: String!)

    Objective-C

    - (void)encodeCMTimeMapping:(CMTimeMapping)timeMapping forKey:(NSString *)key

    Parameters

    timeMapping

    A CMTimeMapping structure.

    key

    The key with which to associate timeMapping in the archive.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Decodes an array of count items, whose Objective-C type is given by itemType.

    Declaration

    Swift

    func decodeArrayOfObjCType(_ itemType: UnsafePointer<Int8>, count count: Int, at array: UnsafeMutablePointer<Void>)

    Objective-C

    - (void)decodeArrayOfObjCType:(const char *)itemType count:(NSUInteger)count at:(void *)array

    Discussion

    The items are decoded into the buffer beginning at address, which must be large enough to contain them all. itemType must contain exactly one type code. NSCoder’s implementation invokes decodeValueOfObjCType:at: to decode the entire array of items.

    This method matches an encodeArrayOfObjCType:count:at: message used during encoding.

    For information on creating an Objective-C type code suitable for itemType, see Type Encodings.

    Special Considerations

    You should not use this method to decode C arrays of Objective-C objects. For historical reasons, returned objects will have an additional ownership reference which you can only relinquish using CFRelease.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns a boolean value that was previously encoded with encodeBool:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeBoolForKey(_ key: String) -> Bool

    Objective-C

    - (BOOL)decodeBoolForKey:(NSString *)key

    Discussion

    Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes a buffer of data that was previously encoded with encodeBytes:length:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeBytesForKey(_ key: String, returnedLength lengthp: UnsafeMutablePointer<Int>) -> UnsafePointer<UInt8>

    Objective-C

    - (const uint8_t *)decodeBytesForKey:(NSString *)key returnedLength:(NSUInteger *)lengthp

    Discussion

    The buffer’s length is returned by reference in lengthp. The returned bytes are immutable. Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes a buffer of data whose types are unspecified.

    Declaration

    Swift

    func decodeBytesWithReturnedLength(_ lengthp: UnsafeMutablePointer<Int>) -> UnsafeMutablePointer<Void>

    Objective-C

    - (void *)decodeBytesWithReturnedLength:(NSUInteger *)lengthp

    Discussion

    NSCoder’s implementation invokes decodeValueOfObjCType:at: to decode the data as a series of bytes, which this method then places into a buffer and returns. The buffer’s length is returned by reference in numBytes. If you need the bytes beyond the scope of the current @autoreleasepool block, you must copy them.

    This method matches an encodeBytes:length: message used during encoding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns an NSData object that was previously encoded with encodeDataObject:. Subclasses must override this method.

    Declaration

    Swift

    func decodeDataObject() -> NSData?

    Objective-C

    - (NSData *)decodeDataObject

    Discussion

    The implementation of your overriding method must match the implementation of your encodeDataObject: method. For example, a typical encodeDataObject: method encodes the number of bytes of data followed by the bytes themselves. Your override of this method must read the number of bytes, create an NSData object of the appropriate size, and decode the bytes into the new NSData object.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns a double value that was previously encoded with either encodeFloat:forKey: or encodeDouble:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeDoubleForKey(_ key: String) -> Double

    Objective-C

    - (double)decodeDoubleForKey:(NSString *)key

    Discussion

    Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns a float value that was previously encoded with encodeFloat:forKey: or encodeDouble:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeFloatForKey(_ key: String) -> Float

    Objective-C

    - (float)decodeFloatForKey:(NSString *)key

    Discussion

    If the value was encoded as a double, the extra precision is lost. If the encoded real value does not fit into a float, the method raises an NSRangeException. Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns an int value that was previously encoded with encodeInt:forKey:, encodeInteger:forKey:, encodeInt32:forKey:, or encodeInt64:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeIntForKey(_ key: String) -> Int32

    Objective-C

    - (int)decodeIntForKey:(NSString *)key

    Discussion

    If the encoded integer does not fit into the default integer size, the method raises an NSRangeException. Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns an NSInteger value that was previously encoded with encodeInt:forKey:, encodeInteger:forKey:, encodeInt32:forKey:, or encodeInt64:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeIntegerForKey(_ key: String) -> Int

    Objective-C

    - (NSInteger)decodeIntegerForKey:(NSString *)key

    Discussion

    If the encoded integer does not fit into the NSInteger size, the method raises an NSRangeException. Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns a 32-bit integer value that was previously encoded with encodeInt:forKey:, encodeInteger:forKey:, encodeInt32:forKey:, or encodeInt64:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeInt32ForKey(_ key: String) -> Int32

    Objective-C

    - (int32_t)decodeInt32ForKey:(NSString *)key

    Discussion

    If the encoded integer does not fit into a 32-bit integer, the method raises an NSRangeException. Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns a 64-bit integer value that was previously encoded with encodeInt:forKey:, encodeInteger:forKey:, encodeInt32:forKey:, or encodeInt64:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeInt64ForKey(_ key: String) -> Int64

    Objective-C

    - (int64_t)decodeInt64ForKey:(NSString *)key

    Discussion

    Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes an Objective-C object that was previously encoded with any of the encode...Object: methods.

    Declaration

    Swift

    func decodeObject() -> AnyObject?

    Objective-C

    - (id)decodeObject

    Discussion

    NSCoder’s implementation invokes decodeValueOfObjCType:at: to decode the object data.

    Subclasses may need to override this method if they override any of the corresponding encode...Object: methods. For example, if an object was encoded conditionally using the encodeConditionalObject: method, this method needs to check whether the object had actually been encoded.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns an Objective-C object that was previously encoded with encodeObject:forKey: or encodeConditionalObject:forKey: and associated with the string key.

    Declaration

    Swift

    func decodeObjectForKey(_ key: String) -> AnyObject?

    Objective-C

    - (id)decodeObjectForKey:(NSString *)key

    Discussion

    Subclasses must override this method if they perform keyed coding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes a single value, whose Objective-C type is given by valueType.

    Declaration

    Swift

    func decodeValueOfObjCType(_ type: UnsafePointer<Int8>, at data: UnsafeMutablePointer<Void>)

    Objective-C

    - (void)decodeValueOfObjCType:(const char *)type at:(void *)data

    Discussion

    valueType must contain exactly one type code, and the buffer specified by data must be large enough to hold the value corresponding to that type code. For information on creating an Objective-C type code suitable for valueType, see Type Encodings.

    Subclasses must override this method and provide an implementation to decode the value. In your overriding implementation, decode the value into the buffer beginning at data.

    This method matches an encodeValueOfObjCType:at: message used during encoding.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • Decodes a series of potentially different Objective-C types.

    Declaration

    Objective-C

    - (void)decodeValuesOfObjCTypes:(const char *)types, ...

    Discussion

    valueTypes is a single C string containing any number of type codes. The variable arguments to this method consist of one or more pointer arguments, each of which specifies the buffer in which to place a single decoded value. For each type code in valueTypes, you must specify a corresponding pointer argument whose buffer is large enough to hold the decoded value.

    This method matches an encodeValuesOfObjCTypes: message used during encoding.

    NSCoder’s implementation invokes decodeValueOfObjCType:at: to decode individual types. Subclasses that implement the decodeValueOfObjCType:at: method do not need to override this method.

    For information on creating Objective-C type codes suitable for valueTypes, see Type Encodings.

    Special Considerations

    You should not use this method to decode Objective-C objects. See decodeArrayOfObjCType:count:at: for more details.

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in iOS 2.0 and later.

  • Decodes an object for the key, restricted to the specified class.

    Declaration

    Swift

    func decodeObjectOfClass(_ aClass: AnyClass, forKey key: String) -> AnyObject?

    Objective-C

    - (id)decodeObjectOfClass:(Class)aClass forKey:(NSString *)key

    Parameters

    aClass

    The expect class type.

    key

    The coder key.

    Return Value

    The decoded object.

    Discussion

    If the coder responds YEStrue to requiresSecureCoding, then an exception will be thrown if the class to be decoded does not implement NSSecureCoding or is not isKindOfClass: of aClass.

    If the coder responds NOfalse to requiresSecureCoding, then the class argument is ignored and no check of the class of the decoded object is performed, exactly as if decodeObjectForKey: had been called.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 6.0 and later.

  • Decodes an object for the key, restricted to the specified classes.

    Declaration

    Swift

    func decodeObjectOfClasses(_ classes: Set<NSObject>, forKey key: String) -> AnyObject?

    Objective-C

    - (id)decodeObjectOfClasses:(NSSet *)classes forKey:(NSString *)key

    Parameters

    classes

    A set of the expected classes.

    key

    The coder key.

    Return Value

    The decoded object.

    Discussion

    The class of the object may be any class in the classes set, or a subclass of any class in the set. Otherwise, the behavior is the same as decodeObjectOfClass:forKey:.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 6.0 and later.

  • Returns a decoded property list for the specified key.

    Declaration

    Swift

    func decodePropertyListForKey(_ key: String) -> AnyObject?

    Objective-C

    - (id)decodePropertyListForKey:(NSString *)key

    Parameters

    key

    The coder key.

    Return Value

    A decoded object containing a property list.

    Discussion

    This method calls decodeObjectOfClasses:forKey: with a set allowing only property list types.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 6.0 and later.

  • Decodes and returns the CGPoint structure associated with the specified key in the receiver’s archive.

    Declaration

    Swift

    func decodeCGPointForKey(_ key: String!) -> CGPoint

    Objective-C

    - (CGPoint)decodeCGPointForKey:(NSString *)key

    Parameters

    key

    The key that identifies the point.

    Return Value

    The CGPoint structure.

    Discussion

    Use this method to decode a point that was previously encoded using the encodeCGPoint:forKey: method.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns the CGRect structure associated with the specified key in the receiver’s archive.

    Declaration

    Swift

    func decodeCGRectForKey(_ key: String!) -> CGRect

    Objective-C

    - (CGRect)decodeCGRectForKey:(NSString *)key

    Parameters

    key

    The key that identifies the rectangle.

    Return Value

    The CGRect structure.

    Discussion

    Use this method to decode a rectangle that was previously encoded using the encodeCGRect:forKey: method.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns the CGSize structure associated with the specified key in the receiver’s archive.

    Declaration

    Swift

    func decodeCGSizeForKey(_ key: String!) -> CGSize

    Objective-C

    - (CGSize)decodeCGSizeForKey:(NSString *)key

    Parameters

    key

    The key that identifies the size information.

    Return Value

    The CGSize structure.

    Discussion

    Use this method to decode size information that was previously encoded using the encodeCGSize:forKey: method.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns the CGAffineTransform structure associated with the specified key in the receiver’s archive.

    Declaration

    Swift

    func decodeCGAffineTransformForKey(_ key: String!) -> CGAffineTransform

    Objective-C

    - (CGAffineTransform)decodeCGAffineTransformForKey:(NSString *)key

    Parameters

    key

    The key that identifies the affine transform.

    Return Value

    The affine transform.

    Discussion

    Use this method to decode size information that was previously encoded using the encodeCGAffineTransform:forKey: method.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns the UIEdgeInsets structure associated with the specified key in the receiver’s archive.

    Declaration

    Swift

    func decodeUIEdgeInsetsForKey(_ key: String!) -> UIEdgeInsets

    Objective-C

    - (UIEdgeInsets)decodeUIEdgeInsetsForKey:(NSString *)key

    Parameters

    key

    The key that identifies the edge insets.

    Return Value

    The edge insets data.

    Discussion

    Use this method to decode size information that was previously encoded using the encodeUIEdgeInsets:forKey: method.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 2.0 and later.

  • Decodes and returns the UIOffset structure associated with the specified key in the receiver’s archive.

    Declaration

    Swift

    func decodeUIOffsetForKey(_ key: String!) -> UIOffset

    Objective-C

    - (UIOffset)decodeUIOffsetForKey:(NSString *)key

    Parameters

    key

    The key that identifies the offset.

    Return Value

    The offset data.

    Discussion

    Use this method to decode offset information that was previously encoded using the encodeUIOffset:forKey: method.

    Import Statement

    Objective-C

    @import UIKit;

    Swift

    import UIKit

    Availability

    Available in iOS 5.0 and later.

  • Returns the CMTime structure associated with a given key.

    Declaration

    Swift

    func decodeCMTimeForKey(_ key: String!) -> CMTime

    Objective-C

    - (CMTime)decodeCMTimeForKey:(NSString *)key

    Parameters

    key

    The key for a CMTime structure encoded in the receiver.

    Return Value

    The CMTime structure associated with key in the archive.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Returns the CMTimeRange structure associated with a given key.

    Declaration

    Swift

    func decodeCMTimeRangeForKey(_ key: String!) -> CMTimeRange

    Objective-C

    - (CMTimeRange)decodeCMTimeRangeForKey:(NSString *)key

    Parameters

    key

    The key for a CMTimeRange structure encoded in the receiver.

    Return Value

    The CMTimeRange structure associated with key in the archive.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Returns the CMTimeMapping structure associated with a given key.

    Declaration

    Swift

    func decodeCMTimeMappingForKey(_ key: String!) -> CMTimeMapping

    Objective-C

    - (CMTimeMapping)decodeCMTimeMappingForKey:(NSString *)key

    Parameters

    key

    The key for a CMTimeMapping structure encoded in the receiver.

    Return Value

    The CMTimeMapping structure associated with key in the archive.

    Import Statement

    Objective-C

    @import AVFoundation;

    Swift

    import AVFoundation

    Availability

    Available in iOS 4.0 and later.

  • Boolean value that indicates whether the coder requires secure coding. (read-only)

    Declaration

    Swift

    var requiresSecureCoding: Bool { get }

    Objective-C

    @property(readonly) BOOL requiresSecureCoding

    Discussion

    YEStrue if this coder requires secure coding; NOfalse otherwise.

    Secure coders check a set of allowed classes before decoding objects, and all objects must implement the NSSecureCoding protocol.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 6.0 and later.

  • The set of coded classes allowed for secure coding. (read-only)

    Declaration

    Swift

    var allowedClasses: Set<NSObject>? { get }

    Objective-C

    @property(readonly, copy) NSSet *allowedClasses

    Discussion

    Secure coders check this set of allowed classes before decoding objects, and all objects must implement the NSSecureCoding protocol.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 6.0 and later.

  • The system version in effect for the archive. (read-only)

    Declaration

    Swift

    var systemVersion: UInt32 { get }

    Objective-C

    @property(readonly) unsigned int systemVersion

    Discussion

    During encoding, the current version. During decoding, the version that was in effect when the data was encoded.

    Subclasses that implement decoding must override this property to return the system version of the data being decoded.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • This method is present for historical reasons and is not used with keyed archivers.

    Declaration

    Swift

    func versionForClassName(_ className: String) -> Int

    Objective-C

    - (NSInteger)versionForClassName:(NSString *)className

    Return Value

    The version in effect for the class named className or NSNotFound if no class named className exists.

    Discussion

    The version number does apply not to NSKeyedArchiver/NSKeyedUnarchiver. A keyed archiver does not encode class version numbers.

    Import Statement

    Objective-C

    @import Foundation;

    Swift

    import Foundation

    Availability

    Available in iOS 2.0 and later.

  • This method is present for historical reasons and has no effect.

    Declaration

    Objective-C

    - (NSZone *)objectZone

    Discussion

    NSCoder’s implementation returns the default memory zone, as given by NSDefaultMallocZone().

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in iOS 2.0 and later.

  • This method is present for historical reasons and has no effect.

    Declaration

    Objective-C

    - (void)setObjectZone:(NSZone *)zone

    Import Statement

    Objective-C

    @import Foundation;

    Availability

    Available in iOS 2.0 and later.