Hillegass Challenges...a question

Discussion in 'Mac Programming' started by mdeh, Mar 18, 2009.

  1. macrumors 6502

    Joined:
    Jan 3, 2009
    #1
    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
     
  2. macrumors 6502

    hankolerd

    Joined:
    Sep 19, 2007
    Location:
    Seattle, WA
    #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:
     
  3. thread starter macrumors 6502

    Joined:
    Jan 3, 2009
    #3

    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
     
  4. Administrator

    Doctor Q

    Staff Member

    Joined:
    Sep 19, 2002
    Location:
    Los Angeles
    #4
    I don't think any forum rules apply to this, so that makes it OK.
     
  5. macrumors 601

    themoonisdown09

    Joined:
    Nov 19, 2007
    Location:
    Georgia, USA
    #5
    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.
     

Share This Page