为什么 NSSearchPathForDirectoriesInDomains 返回一个 NSArray? [英] Why NSSearchPathForDirectoriesInDomains returns an NSArray?
问题描述
为什么 NSSearchPathForDirectoriesInDomains 返回一个 NSArray 而不是一个包含找到路径的 NSString?
Why does NSSearchPathForDirectoriesInDomains return an NSArray instead of a NSString with the path found?
推荐答案
根据 NSSearchPathDirectory 和 NSSearchPathDomainMask,可能存在多个目录.例如,我可以在我的主目录中有一个应用程序文件夹,这是我的用户域.并且在系统域中还有一个 Applications 文件夹.以及网络域中的应用程序文件夹.所以如果我这样做:
Depending on NSSearchPathDirectory and NSSearchPathDomainMask, it is possible that there are multiple directories. For example, i can have an Applications Folder in my Home Directory, which is my User Domain. And Also have an Applications folder in the System Domain. And an application folder in the Network Domain. SO if i do this:
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSApplicationDirectory, NSAllDomainsMask, YES);
它会返回一个路径数组.一个是用户域中Applications文件夹的路径,一个是系统域中的文件夹,一个是网络域中的文件夹.
It will return me an array of paths. One for the path of Applications folder in User Domain, one for the folder in System Domain and one in the network Domain.
这篇关于为什么 NSSearchPathForDirectoriesInDomains 返回一个 NSArray?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!