Class CPKeyedUnarchiver

CPObject
    extended byCPCoder
        extended byCPKeyedUnarchiver

@implementation CPKeyedUnarchiver : CPCoder

CPKeyedUnarchiver is used for creating objects out of coded files or CPData objects that were created by CPKeyedArchiver. More specifically, this class unarchives objects from a data stream or file and brings them back into memory for programmatic usage.


Method Summary
+(id)unarchiveObjectWithData:(CPData)data
          Unarchives the object graph in the provided data object.
+(id)unarchiveObjectWithFile:(CPString)aFilePath
          Not implemented.
+(id)unarchiveObjectWithFile:(CPString)aFilePath asynchronously:(BOOL)aFlag
          Not implemented.
-(id)initForReadingWithData:(CPData)data
          Initializes the receiver to unarchive objects from the specified data object.
-(BOOL)allowsKeyedCoding
          Returns a flag indicating whether the receiver supports keyed coding.
-(BOOL)containsValueForKey:(CPString)aKey
          Returns YES if an object exists for aKey.
-(BOOL)decodeBoolForKey:(CPString)aKey
          Decodes a BOOL from the archive.
-(double)decodeDoubleForKey:(CPString)aKey
          Decodes a double from the archive.
-(float)decodeFloatForKey:(CPString)aKey
          Decodes a float from the archive.
-(int)decodeIntForKey:(CPString)aKey
          Decodes an int from the archive.
-(id)decodeObjectForKey:(CPString)aKey
          Decodes an object from the archive.
-(CGPoint)decodePointForKey:(CPString)aKey
          Decodes a CGPoint from the archive.
-(CGRect)decodeRectForKey:(CPString)aKey
          Decodes a CGRect from the archive.
-(CGSize)decodeSizeForKey:(CPString)aKey
          Decodes a CGSize from the archive.
-(id)delegate
          Returns the keyed unarchiver's delegate.
-(void)finishDecoding
          Notifies the delegates that decoding has finished.
-(void)setDelegate:(id)aDelegate
          Sets the unarchiver's delegate.

Methods inherited from class CPObject
initialize, alloc, class, instanceMethodForSelector, instancesRespondToSelector, isSubclassOfClass, load, new, setVersion, superclass, version, init, autorelease, awakeAfterUsingCoder, class, classForCoder, classForKeyedArchiver, className, copy, dealloc, description, doesNotRecognizeSelector, forwardInvocation, hash, isEqual, isKindOfClass, isMemberOfClass, isProxy, methodForSelector, methodSignatureForSelector, mutableCopy, performSelector, performSelector, performSelector, release, replacementObjectForArchiver, replacementObjectForCoder, replacementObjectForKeyedArchiver, respondsToSelector, retain, self, superclass

Methods inherited from class CPCoder
allowsKeyedCoding, encodeBycopyObject, encodeConditionalObject, encodeDataObject, encodeObject, encodePoint, encodePropertyList, encodeRect, encodeRootObject, encodeSize, encodeValueOfObjCType

Delegate Method Summary
-(Class)unarchiver:(CPKeyedUnarchiver)unarchiver cannotDecodeObjectOfClassName:(CPString)name originalClasses:(CPArray)classNames
          Called when the specified class is not available during decoding.
-(id)unarchiver:(CPKeyedUnarchiver)unarchiver didDecodeObject:(id)object
          Called when the unarchiver decodes an object.
-(void)unarchiver:(CPKeyedUnarchiver)unarchiver willReplaceObject:(id)object withObject:(id)newObject
          Called when a decoded object has been substituted with another.
-(void)unarchiverWillFinish:(CPKeyedUnarchiver)unarchiver
          Called when the unarchiver is about to finish decoding.
-(void)unarchiverDidFinish:(CPKeyedUnarchiver)unarchiver
          Called when the unarchiver has finished decoding.


Method Detail

unarchiveObjectWithData

+(id)unarchiveObjectWithData:(CPData)data
Unarchives the object graph in the provided data object.
Parameters:
data - the data from which to read the graph
Returns:
the unarchived object

unarchiveObjectWithFile

+(id)unarchiveObjectWithFile:(CPString)aFilePath
Not implemented
Parameters:
aFilePath

unarchiveObjectWithFile

+(id)unarchiveObjectWithFile:(CPString)aFilePath asynchronously:(BOOL)aFlag
Not implemented
Parameters:
aFilePath
aFlag

initForReadingWithData

-(id)initForReadingWithData:(CPData)data
Initializes the receiver to unarchive objects from the specified data object.
Parameters:
data - the data stream from which to read objects
Returns:
the initialized unarchiver

allowsKeyedCoding

-(BOOL)allowsKeyedCoding
Returns a flag indicating whether the receiver supports keyed coding. The default implementation returns NO. Subclasses supporting keyed coding must override this to return YES.

containsValueForKey

-(BOOL)containsValueForKey:(CPString)aKey
Returns YES if an object exists for aKey.
Parameters:
aKey - the object's associated key

decodeBoolForKey

-(BOOL)decodeBoolForKey:(CPString)aKey
Decodes a BOOL from the archive
Parameters:
aKey - the BOOL's associated key
Returns:
the decoded BOOL

decodeDoubleForKey

-(double)decodeDoubleForKey:(CPString)aKey
Decodes a double from the archive.
Parameters:
aKey - the double's associated key
Returns:
the decoded double

decodeFloatForKey

-(float)decodeFloatForKey:(CPString)aKey
Decodes a float from the archive
Parameters:
aKey - the float's associated key
Returns:
the decoded float

decodeIntForKey

-(int)decodeIntForKey:(CPString)aKey
Decodes an int from the archive.
Parameters:
aKey - the int's associated key
Returns:
the decoded int

decodeObjectForKey

-(id)decodeObjectForKey:(CPString)aKey
Decodes an object from the archive.
Parameters:
aKey - the object's associated key
Returns:
the decoded object

decodePointForKey

-(CGPoint)decodePointForKey:(CPString)aKey
Decodes a CGPoint from the archive.
Parameters:
aKey - the point's associated key
Returns:
the decoded point

decodeRectForKey

-(CGRect)decodeRectForKey:(CPString)aKey
Decodes a CGRect from the archive.
Parameters:
aKey - the rectangle's associated key
Returns:
the decoded rectangle

decodeSizeForKey

-(CGSize)decodeSizeForKey:(CPString)aKey
Decodes a CGSize from the archive.
Parameters:
aKey - the size's associated key
Returns:
the decoded size

delegate

-(id)delegate
Returns the keyed unarchiver's delegate

finishDecoding

-(void)finishDecoding
Notifies the delegates that decoding has finished.

setDelegate

-(void)setDelegate:(id)aDelegate
Sets the unarchiver's delegate
Parameters:
aDelegate

Delegate Method Detail

unarchiver

-(Class)unarchiver:(CPKeyedUnarchiver)unarchiver cannotDecodeObjectOfClassName:(CPString)name originalClasses:(CPArray)classNames
Called when the specified class is not available during decoding. The delegate may load the class, or return a substitute class to use instead.
Parameters:
unarchiver - the unarchiver performing the decode
name - the name of the class that can't be found
classNames
Returns:
the Class to use instead or nil to abort the unarchiving operation

unarchiver

-(id)unarchiver:(CPKeyedUnarchiver)unarchiver didDecodeObject:(id)object
Called when the unarchiver decodes an object.
Parameters:
unarchiver - the unarchiver doing the decoding
object - the decoded objec
Returns:
a substitute to use for the decoded object. This can be the same object argument provide, another object or nil.

unarchiver

-(void)unarchiver:(CPKeyedUnarchiver)unarchiver willReplaceObject:(id)object withObject:(id)newObject
Called when a decoded object has been substituted with another. (for example, from unarchiver:didDecodeObject:.
Parameters:
unarchiver - the unarchiver that decoded the object
object - the original decoded object
newObject - the replacement object

unarchiverWillFinish

-(void)unarchiverWillFinish:(CPKeyedUnarchiver)unarchiver
Called when the unarchiver is about to finish decoding.
Parameters:
unarchiver - the unarchiver that's about to finish

unarchiverDidFinish

-(void)unarchiverDidFinish:(CPKeyedUnarchiver)unarchiver
Called when the unarchiver has finished decoding.
Parameters:
unarchiver - the unarchiver that finished decoding

Created on Sat Sep 13 14:15:43 PDT 2008