获取iOS应用程序的“〜/ Library”可靠的路径 [英] Getting an iOS application's "~/Library" path reliably
问题描述
http://developer.apple.com/library/ios/#qa/qa2010/qa1699.html
建议储存位于〜/ Library
之外的子目录中的internal用户文档。但我无法找到一个预先创建的搜索域,这将使我这个。什么是最好的/最正确的/最不可能打破这种路径的方式?
谢谢。
正确的方法是
NSString * path;
path = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory,NSUserDomainMask,YES)[0];
然而, Swift 3: This Apple tech note: http://developer.apple.com/library/ios/#qa/qa2010/qa1699.html suggests storing "internal" user documents in a subdirectory off of Thanks. The correct way is However, Swift 3:
这篇关于获取iOS应用程序的“〜/ Library”可靠的路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋! [@〜/ LibrarystringByExpandingTildeInPath] $ c
let path = NSSearchPathForDirectoriesInDomains(.libraryDirectory,.userDomainMask,true)[0]
~/Library
. But I can't find one of the pre-created search domains that would get me this. What's the best/most correct/least likely to ever break way of constructing this path?NSString* path;
path = NSSearchPathForDirectoriesInDomains(NSLibraryDirectory, NSUserDomainMask, YES)[0];
[@"~/Library" stringByExpandingTildeInPath]
also works.
let path = NSSearchPathForDirectoriesInDomains(.libraryDirectory, .userDomainMask, true)[0]