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

ExoticFish

macrumors 6502a
Original poster
I've been reading Cocoa Programming for Mac OS X and have been finding it enjoyable thus far. The challenge at the end of chapter 5 has been giving me fits however. I just can't make it work.

I've looked around online and it seems that everyone else's solutions are exactly what I'm doing but for some reason I can not get it to work.

here's a site that describes exactly how I tried to solve the problem but when I run the compiled application it does not work! I'm thinking that perhaps it could have something to do with the book's teaching of 10.3 instead of 10.4 but I've seen other people saying they were programming in 10.4

I'm trying to get this to work before I move on to chapter 6. Any help would be greatly appreciated!
 

whooleytoo

macrumors 604
Aug 2, 2002
6,607
716
Cork, Ireland.
Just tried (on 10.4), and works fine here.

I'd imagine the most likely problems are the window's delegate hasn't been set, or there's a typo in the windowWillResize: method name? Other than that, I can't think what could be wrong - there's not a lot of code to get wrong! ;)
 

ExoticFish

macrumors 6502a
Original poster
ok here's what i'm doing:

* i made a subclass of NSObject called AppController, created files, and instantiate it

*AppController.h contains:

Code:
/* AppController */

#import <Cocoa/Cocoa.h>

@interface AppController : NSObject
{
}

- (NSSize)windowWillResize:(NSWindow *)sender
					tosize:(NSSize)frameSize;

@end

*AppController.m contains:
Code:
#import "AppController.h"

@implementation AppController
{
	
}

- (NSSize)windowWillResize:(NSWindow *)sender
					tosize:(NSSize)frameSize
{
	NSLog(@"calling windowWillResize");
	frameSize.width = frameSize.height * 2;
	return frameSize;
}

@end

* in Interface Builder I ctrl drag from Window in the Instances tab to the Instance of AppController and connected the delegate

What am i missing?
 

whooleytoo

macrumors 604
Aug 2, 2002
6,607
716
Cork, Ireland.
No, that looks pretty good actually.

I hope I don't sound condescending, but could you have forgotten to save the changes in the .nib file? Or perhaps when connecting the delegate, you clicked on "delegate" in the list, but never clicked "Connect" (or double clicked, which does the same thing)?
 

ExoticFish

macrumors 6502a
Original poster
hey I'm a noob to Cocoa to condescend away! :D But I did make sure to do both of those things. Here's an image of IB
 

Attachments

  • Picture-1.jpg
    Picture-1.jpg
    78.8 KB · Views: 176

whooleytoo

macrumors 604
Aug 2, 2002
6,607
716
Cork, Ireland.
No problem, you should find it attached.

If nothing appears different, I can provide code that would check if the window's delegate is set correctly at run-time, this would seem to me to be the most likely problem.
 

Attachments

  • CocoaTest.zip
    39.8 KB · Views: 189

ExoticFish

macrumors 6502a
Original poster
Wow

That's all i can really say.

I thank you for you help, but I found the problem finally. In my code posted here you will find my error. tosize: should be toSize:

nothing more to see here folks, move along!

:rolleyes:

seriously though, thanks for taking the time to help out a noob!
 

Catfish_Man

macrumors 68030
Sep 13, 2001
2,579
2
Portland, OR
ExoticFish said:
Wow

That's all i can really say.

I thank you for you help, but I found the problem finally. In my code posted here you will find my error. tosize: should be toSize:

nothing more to see here folks, move along!

:rolleyes:

seriously though, thanks for taking the time to help out a noob!

Ways to find that sort of problem:
1) use autocomplete a lot
2) read the compile warnings closely
 

slooksterPSV

macrumors 68040
Apr 17, 2004
3,544
306
Nowheresville
Fairly said:
Off topic, but don't waste your time with that book. Get the Yacktman book instead.
I strongly disagree with your post, I think that Cocoa Programming for Mac OS X was and still is an awesome book. It teaches you how to use Cocoa very benefitially.

To the Poster: when you finish the book, look up online tutorials for Core Data. OMG That is crazy, it is so cool that I mean I just wow, I created 2 apps in less than 1 hour. My MDM - MoneyData Manager, I recreated that in 10 min. with CoreData, it didn't have EVERYTHING in it, but it had the basics for what I wanted to do. I also made ADM - Assignment Data Manager. -This took longer because I wasn't sure how to do something, but it just automatically worked when I tried it, so yeah.
 

HiRez

macrumors 603
Jan 6, 2004
6,265
2,629
Western US
I agree that the Hillegass book is the best introduction to Cocoa programming. However, the Anguish/Buck/Yacktman book (Cocoa Programming) is also awesome. Where Hillegass is more of a tutorial approach, Anguish is more of a reference and sample-code approach. It's an excellent, comprehensive book, the only problem is it is very out of date (it's 4 years old). I believe it was written when Jaguar (10.2) was still pre-release. That means no discussion of Cocoa Bindings, no Core Data, no Core Image, "Xcode" didn't even exist, and it has some now-deprecated API listings. I still use it from time to time though, it's a shame they don't do a fresh update to it.
 

ExoticFish

macrumors 6502a
Original poster
so many responses, thanks.

@aquanutz
cool, not too far away then. never been to BG although I did drive past it once while heading somewhere. only thing I know about it over there is that a friend of mine went to his first year of college there before moving back and going to Kent.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.