But, then I don't see how to get the keypresses back to my object that has the network connection, to send the command
You could either do what Peter says about NSNotification, or you could create a "_delegate" instance variable, so that your view does something like this in keyDown: delegate = [self delegate];
if ([delegate respondsToSelector:@selector(viewDidReceiveRequest:)]) {
[[self delegate] viewDidReceiveRequest:self];
}
And the delegate implements the method: - (void)viewDidReceiveRequest:(id)theView
{
// do something with the network here
}
The reference to delegate should not be retained. This is called a "weak reference."
by Scott Stevenson — Jan 21
You could either do what Peter says about NSNotification, or you could create a "_delegate" instance variable, so that your view does something like this in keyDown:
delegate = [self delegate]; if ([delegate respondsToSelector:@selector(viewDidReceiveRequest:)]) { [[self delegate] viewDidReceiveRequest:self]; }
And the delegate implements the method:
- (void)viewDidReceiveRequest:(id)theView { // do something with the network here }
The reference to delegate should not be retained. This is called a "weak reference."