Friday, May 3, 2013

NSKeyedUnarchiver finishDecoding example ios


Tells the receiver that you are finished decoding objects.
- (void)finishDecoding
Discussion of [NSKeyedUnarchiver finishDecoding]
Invoking this method allows the receiver to notify its delegate and to perform any final operations on the archive. Once this method is invoked, the receiver cannot decode any further values.
Example of [NSKeyedUnarchiver finishDecoding]
NSData *data = [[NSMutableData alloc]initWithContentsOfFile:YOURFILEPATH];
NSKeyedUnarchiver *unarchiver = [[NSKeyedUnarchiver alloc] initForReadingWithData:data];
YOURDICTIONARY = [unarchiver decodeObjectForKey: YOURDATAKEY];
[unarchiver finishDecoding];
[unarchiver release];
[data release];
Example of [NSKeyedUnarchiver finishDecoding]
- (void)readVenueArchiveFile:(NSString *)inFile key:(NSString *)inKey
    NSMutableData *theData;
    NSKeyedUnarchiver *decoder;

    theData = [[NSData alloc] initWithContentsOfFile:inFile];
    decoder = [[NSKeyedUnarchiver alloc] initForReadingWithData:theData];
    ListClassName *decodedList = [decoder decodeObjectForKey:inKey];
    self.venueIOList = decodedList;
    [decoder finishDecoding];
    [decoder release];
    [theData release];