訪問文件我有一個文件paylines.txt
添加到名爲TextFiles
的文件夾中,該文件夾駐留在iOS項目的Xcode中的Resources
文件夾中。使用[NSBundle mainBundle] pathForResource:ofType:inDirectory:
這是我用來訪問文件的代碼:
NSString* filePath = [[NSBundle mainBundle] pathForResource:@"paylines" ofType:@"txt" inDirectory:@"TextFiles"];
NSLog(@"\n\nthe string %@",filePath);
代碼打印:
2011-06-07 14:47:16.251 slots2[708:207]
the string (null)
是的,就像在鏈接中說的那樣:在彈出窗口中,確保選擇「爲所有添加的文件夾創建文件夾參考」而不是「爲任何添加的文件夾創建組」 – AlvaroSantisteban 2013-01-10 14:42:35