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

mdeh

macrumors 6502
Original poster
Jan 3, 2009
345
2
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

macrumors 6502
Sep 19, 2007
353
6
Seattle, WA
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

macrumors 6502
Original poster
Jan 3, 2009
345
2
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

Code:
- (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

Administrator
Staff member
Sep 19, 2002
39,786
7,521
Los Angeles
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

macrumors 601
Nov 19, 2007
4,319
18
Georgia, USA
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.