iOS上的userDomainMask和localDomainMask等FileManager.SearchPathDomainMask有什么区别?

问题描述

大多数基于文档的 iOS 应用都像这样访问文件系统:

FileManager.default.urls(for: .documentDirectory,in: .userDomainMask).first

我的问题是关于第二个参数 userDomainMask。这在iOS上有什么目的吗?如果是这样,所有选项之间的区别是什么?

不幸的是,Apple 对某些 one-liner docsFileManager.SearchPathDomainMasks 并不能帮助我理解。

解决方法

给你!

typedef NS_OPTIONS(NSUInteger,NSSearchPathDomainMask) {
    NSUserDomainMask = 1,// user's home directory --- place to install user's personal items (~)
    NSLocalDomainMask = 2,// local to the current machine --- place to install items available to everyone on this machine (/Library)
    NSNetworkDomainMask = 4,// publically available location in the local area network --- place to install items available on the network (/Network)
    NSSystemDomainMask = 8,// provided by Apple,unmodifiable (/System)
    NSAllDomainsMask = 0x0ffff  // all domains: all of the above and future items
};