【问题标题】:kCFBundleNameKey returning null when project have multiple targets当项目有多个目标时,kCFBundleNameKey 返回 null
【发布时间】:2012-05-08 21:19:25
【问题描述】:

我正在尝试使用 kCFBundleNameKey 获取捆绑包的短名称

NSString *shortBundleName=[[NSBundle mainBundle] 
        objectForInfoDictionaryKey:(NSString *) kCFBundleNameKey];

它工作正常,但是当我有多个目标由于某种原因它返回 null 时,是否有解决方法?

获取捆绑包工作正常:

NSString *fullBundleName=[[NSBundle mainBundle] objectForInfoDictionaryKey:(NSString *) kCFBundleIdentifierKey];

【问题讨论】:

    标签: iphone xcode null bundle nsbundle


    【解决方案1】:

    CoreFoundation/CFBundle.h:

    CF_EXPORT
    const CFStringRef kCFBundleNameKey;
    /* The human-readable name of the bundle.  
    This key is often found in the InfoPlist.strings 
    since it is usually localized. */
    

    所以,你应该注意你的目标 info.plist

    【讨论】:

      猜你喜欢
      • 2014-09-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多