我使用这个函数来得到在我的项目一个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