User:NSCoder

NSCoder Class Reference

Inherits from NSObject
Conforms to NSObject (NSObject)
Framework /System/Library/Frameworks/Foundation.framework
Availability Available in Mac OS X v10.0 and later.
Declared in NSCoder.h NSGeometry.h

Overview

The NSCoder abstract class declares the interface used by concrete subclasses to transfer objects and other Objective-C data items 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.

Subclassing Notes

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

Tasks

Testing Coder

– allowsKeyedCoding

– containsValueForKey:

Encoding Data

– encodeArrayOfObjCType:count:at:

– encodeBool:forKey:

– encodeBycopyObject:

– encodeByrefObject:

– encodeBytes:length:

– encodeBytes:length:forKey:

– encodeConditionalObject:

– encodeConditionalObject:forKey:

– encodeDataObject:

– encodeDouble:forKey:

– encodeFloat:forKey:

– encodeInt:forKey:

– encodeInteger:forKey:

– encodeInt32:forKey:

– encodeInt64:forKey:

– encodeObject:

– encodeObject:forKey:

– encodePoint:

– encodePoint:forKey:

– encodePropertyList:

– encodeRect:

– encodeRect:forKey:

– encodeRootObject:

– encodeSize:

– encodeSize:forKey:

– encodeValueOfObjCType:at:

– encodeValuesOfObjCTypes:

– encodeNXObject: Deprecated in Mac OS X v10.5

Decoding Data

– decodeArrayOfObjCType:count:at:

– decodeBoolForKey:

– decodeBytesForKey:returnedLength:

– decodeBytesWithReturnedLength:

– decodeDataObject

– decodeDoubleForKey:

– decodeFloatForKey:

– decodeIntForKey:

– decodeIntegerForKey:

– decodeInt32ForKey:

– decodeInt64ForKey:

– decodeObject

– decodeObjectForKey:

– decodePoint

– decodePointForKey:

– decodePropertyList

– decodeRect

– decodeRectForKey:

– decodeSize

– decodeSizeForKey:

– decodeValueOfObjCType:at:

– decodeValuesOfObjCTypes:

– decodeNXObject Deprecated in Mac OS X v10.5

Managing Zones

– objectZone

– setObjectZone:

Getting Version Information

– systemVersion

– versionForClassName:

Content Disclaimer

Informasi ini disarikan dari Wikipedia dan disajikan kembali untuk tujuan edukasi. Konten tersedia di bawah lisensi CC BY-SA 3.0. Kami tidak bertanggung jawab atas ketidakakuratan data yang bersumber dari kontribusi publik tersebut.

  1. The information displayed on this website is sourced in part or in whole from Wikipedia and has been adapted for the purpose of restating it. We strive to provide accurate and relevant information, however:
  2. There is no guarantee of absolute accuracy. Wikipedia is an open, collaborative project that can be edited by anyone, so information is subject to change.
  3. It is not intended to constitute professional advice. The content displayed is for informational and educational purposes only. For important decisions (e.g., medical, legal, or financial), please consult a professional.
  4. Content copyright. Wikipedia is licensed under the Creative Commons Attribution-ShareAlike License (CC BY-SA). This means that content may be reused with appropriate attribution and shared under a similar license.
  5. Responsible use. Any risk arising from the use of information from this website is entirely the responsibility of the user.