【发布时间】:2017-02-21 20:47:26
【问题描述】:
我有一个包含在捆绑包中的文件,其名称如下:
databaseX.sqlite
其中 X 是应用的版本。如果版本为 2.8,则文件应命名为 database2.8.sqlite。当应用程序提交给 Apple 时,我必须确保包含此文件。
是否可以创建编译器指令来检查文件是否在包中?
我试过了,没有成功
#define fileInBundle [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:[NSString stringWithFormat:@"LoteriaMac%@.sqlite", [[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"]]]
#if defined(fileInBundle)
#pragma message("file in bundle")
#else
#pragma message("file missing")
#endif
file in bundle 始终显示,即使文件不在捆绑包中。
【问题讨论】:
标签: ios objective-c cocoa compiler-directives