objective-c class question

Gnomo

Registered
I've started learning Objective-C using the developer documentation and a book Learning Cocoa with Objective-C and for the most part I think I understand the language, so I've decided to try out my own project rather than just working with the examples in the book.

However, I have run into a problem and I though I would ask for some advice, since the project seems to be beyond the scope of the book and I can't find anything in the documentation.

I have two objects: room and exit. The room has an mutable array that is to contain a list of exits. So I have to include "exit.h" in the room.h file so that I won't get an error when I declare the function "- (void)addExit:(exit *)newExit;"

However, I also need to have the exit class point to the room that the exit goes to. So I need the "room.h" file included in the "exit.h" file so that I won't get an error when I declair the property "room * exitsTo;"

Now, regardless of the order in which I include the files in the main program, I get an error that either type exit or type room has not been defined.

Anyone know how I can solve this without changing the objects too much?

Thanks in advance.
 
I have another question for those willing to give it a guess.

I want to my program to be able to receive input from a telnet client. How do I set up communication with the client? how do I send responses?

I've looked into the NSConnection class and NSSocketPort, but I can't make heads or tails of what I need to do.
 
Well, you have a few options:
First, and not a good idea IMHO, is to simply leave commands in a queue in a file somewhere, eg. /tmp.

Second, use signal() (look up "signal" in man) to send signals to your application. then use a signal trap to trap the signal so you can handle it appropriately.

Eg, in an application I wrote, I use:
Code:
signal(SIGHUP, SIG_IGN);
which traps the SIGHUP (hangup, or exit) signal, and ignores it (SIG_IGN) so that it doesn't exit at logout.
 
Back
Top