PDA

View Full Version : Cocoa Programming: Challenge 5




slooksterPSV
Jul 11, 2006, 01:04 AM
I'm stuck on Challenge 5 and I'm not sure what to do on it exactly. Here's what it asks you to do:
--The chapter talks about delegates, maybe I don't completely understand them either:

Delegates are a way of using a function to tell information about another process/function that is executing. For example, you create a synthesizer and if its playing, when you click the stop button, if the synthesizer wasn't finished then it gives you a NO or 0, otherwise if it did finish it'll give you a 1 without you clicking stop. -- Not exactly, but something to that effect

Now for the challange you have to create an object in the window where it will be the delegate and if the window is resized to an arbitrary size, the height will be twice the width. Now I'm not sure if I should have done this in a button or if a regular text label would work, I'm totally not sure how to do this. It gives you the function to use: - (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)frameSize;

And tells you NSSize has 2 properties, I think they were width and height. if someone can give me some pointers on how to do it (not the complete answer) then that'd be great. Thanks you guys, I want to do well with programming and I just need some advice here and there.



slooksterPSV
Jul 11, 2006, 01:18 AM
Duh, I figured it out, you have to link the Window as the delegate since no other item can use the windowWillResize: toSize: method.

I forgot to link Window to my class. I figured it out *hugs* thanks you guys, I know I did it on my own, but thanks still.

MacRumoron
Jul 11, 2006, 10:53 AM
i remember doing this challenge a few months ago :D