I have defined a structure in one class interface. I have used it in that class properly. But I m not able to refer to this structure in other classes. I think I m missing some basics. Generally struct data type defined in one class should be accessible to all the classes in the project right? Why is this not working?
2 Answers
If the struct is declared in your class .h file, you have to import the .h file wherever you need to access the struct.
If you have definitions that need to be shared amongst several modules then it's best to place them in a separate, common header file and import that header file wherever needed. This design is clean and highly extensible.
2 Comments
sridevi
How does this behave in other languages like c. There also do we need importing the file where struct is defined?
Perception
It behaves the same way in C. And by the way, Objective C is just an extension/superset of C.