I am using Xcode to develop a GUI application. I have a model class and a controller class. I have a NSTextView data member in my controller class. How do I access this variable from the model class?
Hi Mecki, Thanks for the reply. If I try using the Controller object inside my Model method by just including "Controller.h" I get loads of errors. Since the #import thing is recursive. i.e. Controller.h already has Model.h and now if I again import Controller.h in Model.h the compiler just gets confused. Any ideas how can I resolve this to let the controller object get the content status from the model.
Re: the recursive #import
problem, what you're looking for is the @class
directive. In most cases, all your class interface needs to know about other classes is their names, since all of the actual implementation-specific stuff is in your *.m
files. The @class
directive therefore provides a way for an interface definition to tell the compiler "hey, when you come across this word, it's a class name, so don't freak out." When you use @class
in your interface declaration, you shouldn't need to import that class's header file.
The Objective-C 2.0 Programming Language: Class Interface (Referring to Other Classes).