【发布时间】:2011-09-21 11:48:28
【问题描述】:
我正在使用这个函数来获取我项目中 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;
}
它进入 if(mainBundle != nil) 但 appDPath 为空。同样的功能正在另一个项目中工作。为什么它在这里不起作用?有没有其他方法可以在项目中获取 plist 文件的路径。提前致谢。
【问题讨论】:
-
你项目的资源中是否真的有一个文件
MyAppSettings.plist? -
是的。我的项目资源中有 MyAppSettings.plist。
标签: iphone objective-c xcode ios4 plist