2014-09-01 35 views
1

我正在開發一個其他開發人員創建的iOS項目,我在運行此應用程序時遇到問題。現在,在某些時候,我有下面的代碼,它返回nil並有更多問題,來:NSBundle pathForRes返回nil?

NSString *staticLibraryBundlePath = [[NSBundle mainBundle] pathForResource:@"SRVRTrackingResources" ofType:@"bundle"]; 

我不知道這是什麼實際上是尋找,我將發佈該項目的文件夾的結構:

enter image description here

我不知道哪個文件,它尋找的.plist一個?

有什麼想法?

+1

檢查這個https://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSBundle_Class/Reference/Reference。 HTML#// apple_ref/OCC/instm /一個NSBundle/pathForResource:ofType: – 2014-09-01 10:36:37

回答

3

SRVRTrackingResources是文件夾類型;不是一個包。這就是爲什麼它返回零。

返回值
的完整路徑名的資源文件或如果文件無法找到。如果bundlePath參數指定的包不存在或不是可讀目錄,則此方法也會返回nil。

NSString *filePath = [[NSBundle mainBundle] pathForResource:filename ofType:@"plist"]; 

更多的檢查Link