I am creating two applications: a command-line Foundation application, and a Cocoa application. The command-line will be the server, and the Cocoa is the client.
The Server code is as follows:
The Client code is as follows:
Where both 'theConnection' objects are NSConnections, and 'remoteObject' in the Client is of type id. It appears as though the client connects to the server, but when I attempt to call a method on remoteObject, I get the following error message:
I have been racking my brain for what seems like forever but cannot figure out the problem. Any help would be greatly appreciated. Thanks in advance!
The Server code is as follows:
Code:
theConnection = [NSConnection serviceConnectionWithName: @"atcserver" rootObject: planes];
if(theConnection == nil) NSLog(@"Error creating Server!");
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(clientHasConnected:) name: NSConnectionDidInitializeNotification object: theConnection];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(connectionHasDied:) name: NSConnectionDidDieNotification object: theConnection];
[theConnection setDelegate: self];
//Make sure the connections runs on its own thread
[theConnection runInNewThread];
//Remove the connection from the main run loop so all requests run on the specified thread
[theConnection removeRunLoop: [NSRunLoop currentRunLoop]];
The Client code is as follows:
Code:
theConnection = [NSConnection connectionWithRegisteredName: @"atcserver" host: nil];
remoteObject = (NSMutableArray *)[[theConnection rootProxy] retain];
if (theConnection == nil) {
NSLog(@"Could not connect to server!");
exit(1);
}
else {
//Add self to the notification center to let it know if the connection has initalized or died
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(connectionHasDied:) name: NSConnectionDidDieNotification object: theConnection];
//Make sure the connections runs on its own thread
[theConnection runInNewThread];
//Remove the connection from the main run loop so all requests run on the specified thread
[theConnection removeRunLoop: [NSRunLoop currentRunLoop]];
}
Where both 'theConnection' objects are NSConnections, and 'remoteObject' in the Client is of type id. It appears as though the client connects to the server, but when I attempt to call a method on remoteObject, I get the following error message:
2009-03-31 18:50:22.087 ATCClient[2243:10b] *** -[NSCFArray remoteMethod]: unrecognized selector sent to instance 0x12ee70
2009-03-31 18:50:22.089 ATCClient[2243:10b] Error! *** -[NSCFArray remoteMethod]: unrecognized selector sent to instance 0x12ee70
I have been racking my brain for what seems like forever but cannot figure out the problem. Any help would be greatly appreciated. Thanks in advance!