objective c - typedef enum scope in xcode projects -


so, current understanding of enum can use make constants correspond numbers. so,

typedef enum  {     number0 = 0,     number1 = 1,     .     .     .  } numbers; 

would allow me refer 0 number0 in every part of code. seems work fine. however, i'm having trouble figuring out how use in xcode project. example, write 1 class, numbercounter, , include code in header file. then, write class, numbercalculator. if want use same definitions in second class, have a) write classes in same source file, or b) include above code in every file want use numbers?

if include code in 1 class, , exclude in second, (when trying have function return of type numbers) parse issue expected type error, if include code in both, gives error 'redefinition of enumerator'. currently, workaround include code in every file, use preprocessor make sure executed once - i.e:

#ifndef numberdef #define numberdef typedef enum  {     number0 = 0,     number1 = 1,     .     .     .  } numbers; #endif 

this works, feel there should nice simple way of doing this. missing here?

include header it's defined in.


Comments

Popular posts from this blog

c# - SharpSVN - How to get the previous revision? -

c++ - Is it possible to compile a VST on linux? -

url - Querystring manipulation of email Address in PHP -