Help needed with Chapter 5 Challenge from Cocoa Programming for Mac OS X

Discussion in 'Mac Programming' started by ExoticFish, Sep 11, 2006.

  1. macrumors 6502a

    ExoticFish

    Joined:
    Dec 3, 2002
    Location:
    The inner depths of madness, aka Kent, OH
    #1
    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!
     
  2. macrumors 603

    whooleytoo

    Joined:
    Aug 2, 2002
    Location:
    Cork, Ireland.
    #2
    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! ;)
     
  3. thread starter macrumors 6502a

    ExoticFish

    Joined:
    Dec 3, 2002
    Location:
    The inner depths of madness, aka Kent, OH
    #3
    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?
     
  4. macrumors 603

    whooleytoo

    Joined:
    Aug 2, 2002
    Location:
    Cork, Ireland.
    #4
    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)?
     
  5. thread starter macrumors 6502a

    ExoticFish

    Joined:
    Dec 3, 2002
    Location:
    The inner depths of madness, aka Kent, OH
    #5
    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
     

    Attached Files:

  6. thread starter macrumors 6502a

    ExoticFish

    Joined:
    Dec 3, 2002
    Location:
    The inner depths of madness, aka Kent, OH
    #6
    Ok now this is just driving me crazy. Would you mind send me your xcode project so i can test to see if it's just my machine or not? I'd greatly appreciate it!
     
  7. macrumors 603

    whooleytoo

    Joined:
    Aug 2, 2002
    Location:
    Cork, Ireland.
    #7
    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.
     

    Attached Files:

  8. thread starter macrumors 6502a

    ExoticFish

    Joined:
    Dec 3, 2002
    Location:
    The inner depths of madness, aka Kent, OH
    #8
    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!
     
  9. macrumors 68030

    Catfish_Man

    Joined:
    Sep 13, 2001
    Location:
    Portland, OR
    #9
    Ways to find that sort of problem:
    1) use autocomplete a lot
    2) read the compile warnings closely
     
  10. macrumors regular

    Joined:
    Sep 24, 2006
    Location:
    Cambridge UK
    #10
    Off topic, but don't waste your time with that book. Get the Yacktman book instead.
     
  11. macrumors 68030

    slooksterPSV

    Joined:
    Apr 17, 2004
    Location:
    Nowheresville
    #11
    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.
     
  12. macrumors 601

    HiRez

    Joined:
    Jan 6, 2004
    Location:
    Western US
    #12
    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.
     
  13. macrumors regular

    Joined:
    May 9, 2005
    Location:
    Boston, MA (I miss Willoughby, Ohio)
    #13
    totally off topic, but i see you're from Kent. I go to BG. <from left field>
     
  14. thread starter macrumors 6502a

    ExoticFish

    Joined:
    Dec 3, 2002
    Location:
    The inner depths of madness, aka Kent, OH
    #14
    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.
     

Share This Page