• 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: Andy Lee <email@hidden>
  • Date: Tue, 1 Jul 2008 15:18:29 -0400

On Jul 1, 2008, at 3:01 PM, JArod Wen wrote:
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?

This sounds right for you.

When one object X is supposed to know about another object Y, using an instance variable is generally the right approach.

If there is only one instance of Y in the whole program, sometimes a global variable is a reasonable approach, or a singleton instance that can be retrieved by a class method. But this is usually not the right approach for objects that are treated as documents, because an application can usually open multiple documents.

There are other ways objects can know about each other, like KVO and bindings. Sometimes X doesn't need to know about Y all the time, only when certain messages are sent, in which case Y can be passed as an argument in the message.

But the most natural approach in most cases is an instance variable.

I don't know much about using NSDocument, so if you have questions about that perhaps others can help.

--Andy

_______________________________________________

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


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

  • Prev by Date: Re: How to make the FileOwner of a nib file accessible globally in whole project (JArod Wen)
  • Next by Date: PDF printing now blurry
  • Previous 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)
  • Next by thread: Re: How to make the FileOwner of a nib file accessible globally in whole project (JArod Wen)
  • Index(es):
    • Date
    • Thread