Design Element
Comment on "A Roadmap Through Cocoa"
by Scott Stevenson — Jan 21
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."
Back to "A Roadmap Through Cocoa"
Design Element

Copyright © Scott Stevenson 2004-2015