NSMutableArray *esami = [[NSMutableArray alloc] init];
NSArray *paths = NSSearchPathForDirectoriesInDomains
(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
//make a file name to write the data to using the
//documents directory:
NSString *fullFileName = [NSString stringWithFormat:@"%@/new", documentsDirectory];
esami = [NSKeyedUnarchiver unarchiveObjectWithFile:fullFileName];
Esame *add=[[Esame alloc]initWithNome:materia voto:voto crediti:crediti anno:anno];
[esami addObject:add];
[NSKeyedArchiver archiveRootObject:esami toFile:fullFileName];
我无法理解为什么这段代码不起作用..如果我使用已经写在我的根目录中的文件,我可以将新元素添加到我的数组中并写入它但是如果我使用另一个文件(在这种情况下是新的)它不起作用。