关于 NSKeyedArchiver archiveRootObject:toFile:

about NSKeyedArchiver archiveRootObject:toFile:

我有一个非常简单的问题,我就是找不到合适的答案。那是

[NSKeyedArchiver archiveRootObject:value toFile:filePath];

根据苹果文档here,上述函数:

Archives an object graph rooted at a given object by encoding it into a data object then atomically writes the resulting data object to a file at a given path, and returns a Boolean value that indicates whether the operation was successful.

我的问题是,如果我使用相同的文件路径多次调用此函数,它是否会覆盖此文件中的先前值?我可以使用此函数将空数组写入文件吗?

是的,它会覆盖以前的值,是的,您可以使用该函数将一个空数组写入文件。

该方法的实现不关心那里有什么,它会覆盖它。