PDA

View Full Version : Hillegass Challenges...a question




mdeh
Mar 18, 2009, 03:27 AM
Hillegass refuses to publish the solutions to the challenges...which is somewhat childish..but that can be debated, I guess.
May I ask if it would be acceptable to publish our solutions here so that the forum can give some feedback, which would certainly help someone like me.
Thanks



hankolerd
Mar 18, 2009, 08:28 AM
That would be awesome by my standards. I have started the book but haven't really had time to start the challenges, if I had something to compare to maybe it would help me start working through them. :apple:

mdeh
Mar 18, 2009, 10:44 AM
That would be awesome by my standards. I have started the book but haven't really had time to start the challenges, if I had something to compare to maybe it would help me start working through them. :apple:


OK...so the challenge is titled "Make a delegate". Basically, it asks to build a single window application, that is constrained to it's width being twice the height.

I have seen more complicated answers, so I am not sure if this is even correct.

Created a class called Foo. Instantiated this in IB. Then connected *from* the window's delegate to Foo.

Then this code in Foo,m

- (NSSize)windowWillResize:(NSWindow *)window toSize:(NSSize)proposedFrameSize
{
NSSize newSize;
newSize.width = proposedFrameSize.height * 2.0;
newSize.height = proposedFrameSize.height;
NSLog(@"Current Size: Height %g: Width %g", newSize.height, newSize.width);
return newSize;
}

Initial size of the window was set in IB.

A few questions.

I saw one proposed solution that set the outlet of the Window to Foo programmatically. It seems to me, that **if** one can set it in the IB, this would be preferable? Hillegas earlier sets the oulet of speechSynthesizer to a class ( lets say Foo) programmatically, but I thought the reason for this was that that class could not be represented graphically in IB. So, my question is do "real programmers" do it this way.

It does work as expected.

Thanks

Doctor Q
Mar 18, 2009, 12:56 PM
May I ask if it would be acceptable to publish our solutions here so that the forum can give some feedback, which would certainly help someone like me.I don't think any forum rules apply to this, so that makes it OK.

themoonisdown09
Mar 18, 2009, 01:00 PM
I would like to see all the solutions. I went through Cocoa Programming for Mac OS X (3rd edition) last summer. I would like to go through it one more time because I think I'm going to start developing some iPhone applications.