NSMutableData 中是否有层次结构系统?如果是这样,我如何以分层方式加载信息?例子
//Create path to saving location
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSMutableData *gameData;
NSKeyedUnarchiver *decoder;
NSString *documentPath = [documentsDirectory stringByAppendingPathComponent:@"tierSave.dat"];
gameData = [NSData dataWithContentsOfFile:documentPath];
//end
//start loading
for(NSArray* firstData in gameData){
decoder = [[NSKeyedUnarchiver alloc] initForReadingWithData:gameData];
int level1 = [decoder decodeIntegerForKey:level1];
}
//end
但是在 for(NSArray* firstData in gameData) 中,编译器告诉我 gameData 不会响应计数,因为它是 NSMutableData 而不是 NSMutableArray 等,我该如何重新实现上面的代码?