Xcode 应用属性列表路径 - 应用主目录



我是objective-c的新手,想了解如何为应用程序的主目录设置文件路径。对于测试和开发,我一直在手动放入硬盘驱动器上属性列表的路径,但现在我想捆绑它 - 或者只是存档并分发它作为没有 Xcode 测试构建的应用程序进行测试......我一直在使用这个...

NSString* pListPath = @"/Users/-----/Saves/Resourcing/resourcingProperties.plist";
NSMutableDictionary *pListDictionary = [[NSMutableDictionary alloc] initWithContentsOfFile:pListPath];
NSMutableDictionary* interfaceKeysDictionary = [pListDictionary valueForKey:@"Interface Keys"];
NSMutableDictionary* valueSavesDictionary = [pListDictionary valueForKey:@"Value Saves"];
将应用程序捆绑为应用程序文件夹中的独立应用程序

后,如何使用应用程序主目录的路径?

对于您要执行的操作,您不希望或不需要直接读取 plist 文件。你只需打电话:

NSBundle* mainBundle = [NSBundle mainBundle]; // or [NSBundle bundleWithIdentifier]
NSDictionary* infoDict = [mainBundle infoDictionary];
NSMutableDictionary* plistDictionary = [NSMutableDictionary dictionaryWithDictionary:infoDict];

然后,您可以根据需要在代码中添加它。

相关内容

最新更新