If the array or dictionary is the root object you should do
NSData * encodedData = [NSKeyedArchiver archivedDataWithRootObject:someArray];
or
BOOL success = [NSKeyedArchiver archiveRootObject:someArray toFile:filePath];
If it is an instance variable of a custom class, in the -encodeWithCoder:
method should do
[coder encodeObject:someArray forKey:@"someArray"];
and then in the -initWithCoder:
method
someArray = [[coder decodeObjectForKey:@"someArray"] retain];
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…