ios - Proper declaration of global C-constants in Objective-C -
i'm trying declare , initialize global c-variables.
const int numberoftickmarks = 6; const double tickvalues[numberoftickmarks] = {500, 2000, 3000, 4000, 6000, 8000}; when in header file (before @interface), linker error. when in .m file (before @implementation), things seem work desired.
is latter accepted way declare global constants c/objective-c?
your global variables should declared in header file:
extern const int numberoftickmarks; extern const double tickvalues[numberoftickmarks]; without extern, linker errors inevitable.
in implementation file, have define them again this:
const int numberoftickmarks = 6; const double tickvalues[numberoftickmarks] = {500, 2000, 3000, 4000, 6000, 8000};
Comments
Post a Comment