• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Newbie: Getting an NSWindow and setting its delegate
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Newbie: Getting an NSWindow and setting its delegate


  • Subject: Newbie: Getting an NSWindow and setting its delegate
  • From: Martin Linklater <email@hidden>
  • Date: Sat, 30 Jul 2005 15:05:22 +0100

Apologies for a real Newbie question.

I'm going through Aaron Hillegass's book 'Cocoa Programming for Mac OSX' and I'm stuck on the challenge at the end of chapter 5. The challenge is this:

'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 the window always remains twice as tall as it is wide.'

My problem is that I don't quite know how to approach the problem. I've tried two approaches so far, both of which seem to fail:

1) Try to set the delegate of the default Window which is created when I create the project. Problem is, IB doesn't let me Control-drag from the window to my AppController class. I tried to set the windows delegete in code, but although I can see the 'setDelegate' method for NSWindow in the docs I don't know how to actually get a pointer to the window to begin with... How do you 'find' a pointer to the default NSWindow object that is created with the project ?

2) Subclass the NSWindow object and use my own window. I've deleted the instance of the standard window from IB, but IB isn't letting me instantiate my own class... It lets me create a subclass of NSWindow and create the source files for it, but the 'Instantiate this class' menu option is greyed out. Why ? I've tried to create an instance of my subclass in the AppController init method (using [[MyWindow alloc] init] ), but that doesn't seem to create anything, and I can't tell why. It's not throwing errors or anything, but it's not creating a window either. I'm puzzled.

Can anyone point me in the right direction of how I complete this challenge ? I'm not after an in-depth explanation or anything - just a pointer to some docs or a few hints to get my brain working properly.

Thanks for any help you can give.

- Martin
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Newbie: Getting an NSWindow and setting its delegate
      • From: Michael Ströck <email@hidden>
    • Re: Newbie: Getting an NSWindow and setting its delegate
      • From: James Spencer <email@hidden>
    • Re: Newbie: Getting an NSWindow and setting its delegate
      • From: Pontus Ilbring <email@hidden>
  • Prev by Date: Re: NSLayoutManager Background Layout Crash
  • Next by Date: Re: Newbie: Getting an NSWindow and setting its delegate
  • Previous by thread: Re: NSTextField
  • Next by thread: Re: Newbie: Getting an NSWindow and setting its delegate
  • Index(es):
    • Date
    • Thread