CFPreferences创建多个文件 [英] CFPreferences creates multiple files

查看:197
本文介绍了CFPreferences创建多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我只有一个小问题:

为什么CFPreferences-API在我的UserPrefs目录中创建多个文件?所有文件都有我的Bundle-Identifier作为名称,所有(除了一个,原始)添加了一个后缀,像这样:

Why the CFPreferences-API creates multiple files in my UserPrefs-Directory? All the files have my Bundle-Identifier as name and all (except the one, the original) have added a suffix like this:


  • com .myComp.myApp.plist< - (只应创建此plist文件)

  • com.myComp.myApp.plist.0qzcicc

  • com.myComp.myApp.plist.8dhjfht

推荐答案

这看起来非常像副作用

原子写意味着,每当一个文件从 NSData )对象,则首先使用同一目录中的临时文件名创建文件。然后所有数据写入该文件(操作通常不是原子的)。关闭文件后,将其重命名为原始文件名。重命名是一个原子步骤,它确保任何其他可能查看该文件的进程看到完整的旧文件或完整的新文件。没有办法让进程只看到一半的文件。

Atomic writing means that, whenever a file is to be written from an NSData (or other) object, the file is first created using a temporary file name in the same directory. Then all data is written into that file (an operation which is usually not atomic). After closing the file it is renamed to the original file name. The rename is an atomic step, which ensures that any other process that might look at the file sees either the complete old file or the complete new file. There’s no way that a process might see only half of a file.

有趣的命名文件看起来像是从这个过程的工件。也许你的应用程序在一个原子写入中间崩溃了?

The funny named files look like they are artifacts from this process. Maybe your app crashed in the middle of an atomic write?

这篇关于CFPreferences创建多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆