Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

BayAreaMacFan

macrumors member
Original poster
Feb 8, 2007
56
0
So I've just started reading the Learning Cocoa book by Aaron Hillegass. I have some experience in Java and enough familiarity with C to understand everything great so far. I'm in Chapter 6 and one of the challenges is to:

"Create a new application with one window. Make an object that is a Delegate of the window. As the user resizes the window, make sure that it always remains twice as tall as it is wide. Here is the signature of the Delegate method you will implement:
- (NSSize)windowWillResize:(NSWindow *)sender
toSize:(NSSize)frameSize;"

It seems pretty self explanatory and I was able to finish the second and I would assume more difficult challenge that is the to-do list one. I can't seem to wrap my head around the question. I believe I understand how to manipulate NSSize (though I can't test it), but I don't know where to start. Creating an application with only a window should have nothing in the .h file correct? And if so, what do I call in the .m file (i.e. how do I call setDelegate.self on the window)? Thanks in advance.
 
I believe that the books just wants you to create an application that is one window (in Interface Builder) then create a new object (a subclass of NSObject or NSWindowController) to be the delegate.

Otherwise, you can set a delegate to self ([myObject setDelegate:self]) but in this case you would have to subclass NSWindow.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.