我使用這個函數來得到在我的項目一個plist文件的路徑:爲什麼我不能在我的項目中獲得plist文件的路徑?
+ (NSString *) appDataPath{
NSLog(@"in appDataPath");
NSString *appDPath = nil;
// Get the main bundle for the app.
NSBundle* mainBundle = [NSBundle mainBundle];
if (mainBundle != nil) {
NSLog(@"in appDataPath mainbundle");
appDPath = [mainBundle pathForResource:@"MyAppSettings" ofType:@"plist"];
NSLog(@"appDataPath: %@", appDPath);
}
return appDPath;
}
,如果它在(mainBundle =零!),但appDPath爲空。這個相同的功能正在另一個項目中工作。爲什麼它不在這裏工作?有沒有其他方式可以在項目中獲得plist文件的路徑。提前致謝。
在您的項目資源中是否實際存在文件「MyAppSettings.plist」? – DarkDust
是。我的項目資源中有MyAppSettings.plist。 – Piscean