沙盒、URL目录查找

沙盒目录

let path = NSHomeDirectory()
print(path)
print("----------------------")

Documents

let doct1 = path + "/Documents"
print(doct1)
let doct2 = NSSearchPathForDirectoriesInDomains(.DocumentDirectory, .UserDomainMask, true)
print(doct2.first!)
print("----------------------")

Caches

cachesPath1 = NSSearchPathForDirectoriesInDomains(.CachesDirectory, .UserDomainMask, true)
print(cachesPath1.first!)
print("----------------------")

tmp

let tmpPath = path + "/tmp"
print(tmpPath)
print("----------------------")

App

let mainPath = NSBundle.mainBundle().bundlePath
print(mainPath)
let resoursePath = NSBundle.mainBundle().resourcePath
print(resoursePath!)
print("----------------------")

info.plist

let infoPath = mainPath + "/info.plist"
print(infoPath)
print("----------------------")

#Java教程新目录.html
```swift
let htmlPath = NSBundle.mainBundle().pathForResource("Java教程新目录", ofType: "html")
print(htmlPath!)
print("----------------------")

URL: NSURL(2.0)/URL(3.0)

let urlPath = NSURL(fileURLWithPath: htmlPath!)
print(urlPath)
let resURL = NSBundle.mainBundle().URLForResource("Java教程新目录", withExtension: "html")
print(resURL!)
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容