hi folks, im a 42 year old scuba diver bum with a 21 year old computer degree - they taught me cobol !
anyway as part of my transition out of the dive industry im tying to teach myself to program again - and its much harder than when i self taught myself assembly langauge on the vic 20 when i was a teenager
ANyway - ive ploughted thru the apress c and objective c boossand am hitting walls in Hillegass
chapter 6 has 2 exercises - i'm having trouble with the first one - this delegate thing is doing my head in. i get the concept of Delegate methods executing when something has happened.
heres the text from the book - page 109
Challenge: Make a Delegate
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.
my problem is not knowing where to start . ive create a new ap. fine. simple - its the "make an object that is a delegate of the window" . can someone talk me through that linking stage or send me there solution to look at - the coding bit that actually resizes the window i'll be ok with - its that first step
the rest of the challenge
Here is the signature of the Delegate method you will implement:
- (NSSize)windowWillResizeNSWindow *)sender toSizeNSSize)frameSize;
The first argument is the window being resized.
The second argument is a C struct that contains the size that the user has asked for:
typedef struct _NSSize {
float width;
float height; } NSSize;
Here is how you create an NSSize that is 200 points wide and 100 points tall:
NSSize mySize; mySize.width = 200.0; mySize.height = 100.0; NSLog(@"mySize is %f wide and %f tall", mySize.width, mySize.height);
You can set the intial size of the window in the Size Inspector in Interface Builder.
anyway as part of my transition out of the dive industry im tying to teach myself to program again - and its much harder than when i self taught myself assembly langauge on the vic 20 when i was a teenager
ANyway - ive ploughted thru the apress c and objective c boossand am hitting walls in Hillegass
chapter 6 has 2 exercises - i'm having trouble with the first one - this delegate thing is doing my head in. i get the concept of Delegate methods executing when something has happened.
heres the text from the book - page 109
Challenge: Make a Delegate
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.
my problem is not knowing where to start . ive create a new ap. fine. simple - its the "make an object that is a delegate of the window" . can someone talk me through that linking stage or send me there solution to look at - the coding bit that actually resizes the window i'll be ok with - its that first step
the rest of the challenge
Here is the signature of the Delegate method you will implement:
- (NSSize)windowWillResizeNSWindow *)sender toSizeNSSize)frameSize;
The first argument is the window being resized.
The second argument is a C struct that contains the size that the user has asked for:
typedef struct _NSSize {
float width;
float height; } NSSize;
Here is how you create an NSSize that is 200 points wide and 100 points tall:
NSSize mySize; mySize.width = 200.0; mySize.height = 100.0; NSLog(@"mySize is %f wide and %f tall", mySize.width, mySize.height);
You can set the intial size of the window in the Size Inspector in Interface Builder.