我正在尝试从主束的一些信息:转换CFStringRef到的NSString
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
CFStringRef bundleVer = CFBundleGetValueForInfoDictionaryKey(CFBundleGetMainBundle(), kCFBundleVersionKey);
NSString *appVersion = (__bridge NSString *)bundleVer;
}
我能得到CFStringRef(在调试,我可以看到正确的价值联想到的变量),但是当我尝试将其转换为NSString,我的appVersion变量具有“null”值(以前为零)。
我在做什么错?
我正在使用ARC。
编辑:看来,我有问题,我的项目,每一个的NSString对象不能即使一个简单的静态分配分配,测试变量的值(NULL)
NSString *test = @"";
可能重复的[如何将CFStringRef转换为NSString?](http://stackoverflow.com/questions/640367/how-to-convert-cfstringref-to-nsstring) – Gutblender 2014-10-10 14:17:11
你的CFStringRef的值是什么?我复制了你的代码,它完全适用于我的应用程序。 – 2014-10-10 14:17:40
在我的应用程序中也能正常工作.. – 2014-10-10 14:24:34