![](/img/trans.png)
[英]How to view the files/directories created by my iOS app in Xcode
[英]Referencing directories within an Xcode project for an iOS app
我需要能夠引用xCode項目內部目錄中的特定文件。 到目前為止,我有以下代碼:
let files = NSBundle.mainBundle().pathForResource("sampleFile", ofType: "csv")
var contents = String(contentsOfFile: path!, encoding: NSUTF8StringEncoding, error: nil)!
它可以打開一個文件,但是我希望能夠打開一個存儲在主捆綁包中一個或兩個目錄中的文件。
有人知道怎么做這個嗎?
NSBundle有一種方法可以為單個文件指定目錄
let file = NSBundle.mainBundle().pathForResource("sampleFile", ofType: "png", inDirectory:"Images")
或用於相同類型的多個文件
let files = NSBundle.mainBundle().pathForResourcesOfType("png", inDirectory:"Images")
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.