This has nothing to do with classes. This is a feature of C.
If you define a type or an enum in a .h
file, you can use it by importing it (#import
) where you need it.
If you define your enum in a .c
or .m
file, only elements after that definition in the file can use it.
In your case, it appears that you need the same enum in two different files. Usage is to define that enum in a separate file, e.g., knownTypes.h
and import that file in the two files using it: DataClass.m
and TestClass.m
.
If TestClass
is for testing purpose, then your current organization is OK: enum is declared in DataClass.h
and both DataClass.m
and TestClass.m
import DataClass.h
.