Declaring extern NSString causes linker error

后端 未结 4 1650
旧巷少年郎
旧巷少年郎 2021-02-07 11:17

This is ridiculous, im trying to create a sound bool to turn of in app sounds. I keep getting

Undefined symbols for architecture i386:
\"_kPlaySoundPrefsKey\",         


        
4条回答
  •  盖世英雄少女心
    2021-02-07 12:11

    First, ensure it is defined:

    // AppDelegate.h
    extern NSString* const kPlaySoundPrefsKey; // << declaration
    
    // AppDelegate.m
    NSString * const kPlaySoundPrefsKey = @"kPlaySoundPrefsKey";  // << definition
    

    see also:

    "extern const" vs "extern" only

    3 questions about extern used in an Objective-C project

    Linker error using extern "C" in Objective-C code

提交回复
热议问题