• 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
Re: Getting hold of an NSView from an NSDocument
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting hold of an NSView from an NSDocument


  • Subject: Re: Getting hold of an NSView from an NSDocument
  • From: "Michael P. Rogers" <email@hidden>
  • Date: Mon, 11 Feb 2002 08:53:10 -0600

on 2/10/02 8:29 PM, Michael P. Rogers wrote:

I created an NSView subclass
...
Now, however, I'm trying to use it in an NSDocument application. So,
I create an EtchASketch in the nib file (well, I drag a CustomView
and then indicate that it's an EtchASketch). MyDocument has an
IBOutlet called etchy, and I use IB to make the connection.

However, that connection doesn't seem to "last". If I close my
window, then make a new one, etchy is nil.

It is not clear to me what this means. Which window are you closing? The one
in IB? If you close the *Document* window then the view is going to go away.

This is all happening in a running program.

To summarize, when I close a Document window, EtchASketch vanishes. When I create a new Document, I get a new window, with a new EtchASketch, but that's a completely different object, and so the connection that I made in IB between the FileOwner (representing MyDocument) and *that* EtchASketch object has no bearing on what happens when I create a new MyDocument instance, and get a new window. *That* EtchASketch is a different object.

Have I got that right?

The connection you make in IB is very relevant, however it is *also* true
that every nib loaded is a new set of objects.

I see.

> And in this same vein, *can* I load a new MyDocument, and then
programatically tell it where the EtchASketch object is?

Yeah, but there is no reason to do so from your description.

OK. I've reworked the application so that now, instead of EtchASketch having an outlet for MyDocument, MyDocument has an outlet for EtchASketch. I've put all the functionality of EtchASketch into MyDocument (the latter now manages points, and just tells an EtchASketch to draw itself).

This does work as it should. I can close a document window, and when i create a new one, the connection to EtchASketch *is* intact. Why does it work this way and not t'other?


I'm not sure if Tennessee counts as "the other side of the world", but ...

Close enough (or should I say, far enough :-) Thanks very much for your help.

Michael
--
Dr. Michael P. Rogers
Office: 203G Shilling Hall
Phone: 217-424-6327 (W) 309-828-8655 (H) 309-825-6454 (C)
E-Mail: email@hidden

Web site: http://math.millikin.edu/
Astronomy Site: http://twincityamateurastronomers.org
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Prev by Date: Re: newbie question on 'Cocoa Programming for Mac OS X'
  • Next by Date: Re: Localization and international preferences
  • Previous by thread: Re: Getting hold of an NSView from an NSDocument
  • Next by thread: [slightly OT] rant
  • Index(es):
    • Date
    • Thread