• 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: How to make the FileOwner of a nib file accessible globally in whole project (was Re: Cocoa-dev Digest, Vol 5, Issue 1168)
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to make the FileOwner of a nib file accessible globally in whole project (was Re: Cocoa-dev Digest, Vol 5, Issue 1168)


  • Subject: Re: How to make the FileOwner of a nib file accessible globally in whole project (was Re: Cocoa-dev Digest, Vol 5, Issue 1168)
  • From: JArod Wen <email@hidden>
  • Date: Tue, 1 Jul 2008 15:01:00 -0400

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@hidden)

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:
This email sent to email@hidden


  • Follow-Ups:
    • Re: How to make the FileOwner of a nib file accessible globally in whole project (was Re: Cocoa-dev Digest, Vol 5, Issue 1168)
      • From: Andy Lee <email@hidden>
References: 
 >Re: Cocoa-dev Digest, Vol 5, Issue 1168 (From: JArod Wen <email@hidden>)
 >How to make the FileOwner of a nib file accessible globally in whole project (was Re: Cocoa-dev Digest, Vol 5, Issue 1168) (From: Andy Lee <email@hidden>)

  • Prev by Date: Re: How to make the FileOwner of a nib file accessible globally in whole project (JArod Wen)
  • Next by Date: Re: How to make the FileOwner of a nib file accessible globally in whole project (JArod Wen)
  • Previous by thread: How to make the FileOwner of a nib file accessible globally in whole project (was Re: Cocoa-dev Digest, Vol 5, Issue 1168)
  • Next by thread: Re: How to make the FileOwner of a nib file accessible globally in whole project (was Re: Cocoa-dev Digest, Vol 5, Issue 1168)
  • Index(es):
    • Date
    • Thread