Thanks for your fast reply.

On Jul 1, 2008, at 2:36 PM, Andy Lee wrote:

On Jul 1, 2008, at 2:07 PM, JArod Wen wrote:
I need to make some clearance on this problem: the biggest issue is that MovieDocument is instantiated by IB, since it is the FileOwner of the MovieDocument.nib. So the problem should be: is there a way to access a class from a method of another class when the
first class is instantiated from a NIB file.

Either I am misunderstanding you or you are misunderstanding how File's Owner works. File's Owner is *not* instantiated by loading the nib.

Yes you are right. I make mistake on this point. I constructed the project as a cocoa-based NSDocument project, and MovieDocument.mm is the first class from NSDocument. So in fact it is instantiated by the application, right? But for other nibs, file's owner should be initialized before setting it as a file's owner, right?



Here's an explanation I gave earlier, with a few edits:

Unlike most other objects in a nib file (First Responder being the other exception), File's Owner is not a specific object. It is a placeholder for an "owner" object that will be specified when the nib file is loaded by your program.

You edit a nib file knowing the file will be loaded at some point when your program is running, and *at that future time* you will specify the owner of the file (hence "File's Owner" -- it's the second argument to loadNibNamed:owner:). It will be an object that your program created prior to loading the nib.

The File's Owner gives your program access to the objects in the nib file, through the connections you made to it in the nib.


So making your MovieDocument object visible to other classes isn't really affected by the fact that it's a File's Owner for a nib. You can use any of the techniques you'd normally use in code to make one object visible to another.

A way I can find from my head is setting the instant variable in other classes... So all the related classes should have one instant variable like

MovieDocument *movieDocument;

And also the getter and setter. Is there any other way for this purpose?



Note also that a given object can be File's Owner for more than one nib, if that helps.

--Andy



Thanks Andy!
---------------
JArod Wen




_______________________________________________

Cocoa-dev mailing list ([email protected])

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to [EMAIL PROTECTED]

Reply via email to