2015年12月19日 星期六

NSBundle.mainBundle().pathForResource("name", ofType: "type")找不到檔案的解決辦法

在使用NSBundle.mainBundle().pathForResource("fileName", ofType: "type")時,找不到其對應的檔案。
檔案一般是通過右鍵 > "Add Files to 專案名稱" 或直接拖曳的方式增加到該專案中,
但是使用NSBundle.mainBundle().pathForResource("fileName", ofType: "type")時,無論如何都找不到檔案的話,

可以試試用copy Bundle Resources下面的"+"號,手動將檔案加入到你的專案中,這樣也許能解決問題。

沒有留言:

張貼留言

.htaccess應用

去除WWW RewriteEngine On RewriteCond %{HTTP_HOST} ^www\.example\.com $ [ NC ] RewriteRule ^(.*) $ https: / /example.com/ $1 [ R = 301...