CPObjectCPCoder
CPKeyedArchiver
@implementation CPKeyedArchiver : CPCoder
Implements keyed archiving of object graphs. Archiving means to
write data out in a format that be read in again later, or possibly
stored in a file. To read the data back in, use a
CPKeyedUnarchiver
.
Method Summary | |
---|---|
+(BOOL) | allowsKeyedCoding Returns a flag indicating whether the receiver supports keyed coding. |
+(CPData) | archivedDataWithRootObject:(id)anObject Archives the specified object. |
+(CPString) | classNameForClass:(Class)aClass Returns the name of the substitute class used for encoding aClass by all keyed archivers. |
+(void) | setClassName:(CPString)aClassName forClass:(Class)aClass Allows substitution of class types for encoding. |
-(id) | initForWritingWithMutableData:(CPMutableData)data Initializes the keyed archiver with the specified CPMutableData for writing. |
-(CPString) | classNameForClass:(Class)aClass Returns the name of the substitute class used for encoding aClass by this keyed archiver. |
-(id) | delegate Returns the keyed archiver's delegate. |
-(void) | encodeBool:(BOOL)aBOOL forKey:(CPString)aKey Encodes a BOOL value. |
-(void) | encodeConditionalObject:(id)anObject forKey:(CPString)aKey Encodes an conditionally. |
-(void) | encodeDouble:(double)aDouble forKey:(CPString)aKey Encodes a double value. |
-(void) | encodeFloat:(float)aFloat forKey:(CPString)aKey Encodes a float value. |
-(void) | encodeInt:(float)anInt forKey:(CPString)aKey Encodes a int value. |
-(void) | encodeNumber:(CPNumber)aNumber forKey:(CPString)aKey Encodes a number. |
-(void) | encodeObject:(id)anObject forKey:(CPString)aKey Encdoes an object. |
-(void) | encodePoint:(CGPoint)aPoint forKey:(CPString)aKey Encodes a CGPoint . |
-(void) | encodeRect:(CGRect)aRect forKey:(CPString)aKey Encodes a CGRect . |
-(void) | encodeSize:(CGSize)aSize forKey:(CPString)aKey Encodes a CGSize . |
-(void) | finishEncoding Finishes up writing any left over data, and notifies delegates. |
-(CPPropertyListFormat) | outputFormat Returns the property list format used to archive objects. |
-(void) | setClassName:(CPString)aClassName forClass:(Class)aClass Allows substitution of class types for encoding. |
-(void) | setDelegate:(id)aDelegate Sets the keyed archiver's delegate. |
-(void) | setOutputFormat:(CPPropertyListFormat)aPropertyListFormat Sets the property list format the archiver should use to archive objects. |
Methods inherited from class CPCoder |
---|
allowsKeyedCoding, encodeBycopyObject, encodeConditionalObject, encodeDataObject, encodeObject, encodePoint, encodePropertyList, encodeRect, encodeRootObject, encodeSize, encodeValueOfObjCType |
Delegate Method Summary | |
---|---|
-(void) | archiverWillFinish:(CPKeyedArchiver)archiver Called when the encoding is about to finish. |
-(void) | archiver:(CPKeyedArchiver)archiver didEncodeObject:(id)object Called when an object is encoded into the archiver. |
-(void) | archiverDidFinish:(CPKeyedArchiver)archiver Called when the archiver finishes encoding. |
-(id) | archiver:(CPKeyedArchiver)archiver willEncodeObject:(id)object Called when an object is about to be encoded. |
-(void) | archiver:(CPKeyedArchiver)archiver willReplaceObject:(id)object withObject:(id)newObject Called when an object is being replaced in the archiver. |
Method Detail |
---|
+(BOOL)allowsKeyedCoding
NO
. Subclasses supporting keyed coding must override this to return YES
.+(CPData)archivedDataWithRootObject:(id)anObject
anObject
- the object to archive+(CPString)classNameForClass:(Class)aClass
aClass
by all keyed archivers.aClass
- the class to substitutenil
if there
is no substitute class
+(void)setClassName:(CPString)aClassName forClass:(Class)aClass
aClass
encountered by all keyed archivers will
instead be archived as a class of type aClassName
.aClassName
- the substitute class nameaClass
- the class to substitute-(id)initForWritingWithMutableData:(CPMutableData)data
CPMutableData
for writing.data
- the object to archive to-(CPString)classNameForClass:(Class)aClass
aClass
by this keyed archiver.aClass
- the class to substitutenil
if there is no substitute class
-(id)delegate
-(void)encodeBool:(BOOL)aBOOL forKey:(CPString)aKey
BOOL
valueaBOOL
aKey
- the key to associate with the BOOL
-(void)encodeConditionalObject:(id)anObject forKey:(CPString)aKey
anObject
- the object to to conditionally encodeaKey
- the key to associate with the object-(void)encodeDouble:(double)aDouble forKey:(CPString)aKey
double
valueaDouble
- the double
valueaKey
- the key to associate with the double
-(void)encodeFloat:(float)aFloat forKey:(CPString)aKey
float
valueaFloat
- the float
valueaKey
- the key to associate with the float
-(void)encodeInt:(float)anInt forKey:(CPString)aKey
int
valueanInt
- the int
valueaKey
- the key to associate with the int
-(void)encodeNumber:(CPNumber)aNumber forKey:(CPString)aKey
aNumber
- the number to encodeaKey
- the key to associate with the object-(void)encodeObject:(id)anObject forKey:(CPString)aKey
anObject
- the object to encodeaKey
- the key to associate with the object-(void)encodePoint:(CGPoint)aPoint forKey:(CPString)aKey
CGPoint
aPoint
- the point to encodeaKey
- the key to associate with the point-(void)encodeRect:(CGRect)aRect forKey:(CPString)aKey
CGRect
aRect
- the rectangle to encodeaKey
- the key to associate with the rectangle-(void)encodeSize:(CGSize)aSize forKey:(CPString)aKey
CGSize
aSize
- the size to encodeaKey
- the key to associate with the size-(void)finishEncoding
-(CPPropertyListFormat)outputFormat
-(void)setClassName:(CPString)aClassName forClass:(Class)aClass
aClass
encountered by this keyed archiver will
instead be archived as a class of type aClassName
.aClassName
- the substitute class nameaClass
- the class to substitute-(void)setDelegate:(id)aDelegate
aDelegate
-(void)setOutputFormat:(CPPropertyListFormat)aPropertyListFormat
aPropertyListFormat
- the format to useDelegate Method Detail |
---|
-(void)archiverWillFinish:(CPKeyedArchiver)archiver
archiver
- the archiver that's about to finish-(void)archiver:(CPKeyedArchiver)archiver didEncodeObject:(id)object
archiver
- the archiver that encoded the objectobject
- the object that was encoded-(void)archiverDidFinish:(CPKeyedArchiver)archiver
archiver
- the arhiver that finished encoding-(id)archiver:(CPKeyedArchiver)archiver willEncodeObject:(id)object
nil
.archiver
- the archiver encoding the objectobject
- the candidate object for encoding-(void)archiver:(CPKeyedArchiver)archiver willReplaceObject:(id)object withObject:(id)newObject
archiver
- the archiver encoding the objectobject
- the object to be replacednewObject
- the replacement objectCreated on Sat Sep 13 14:15:43 PDT 2008