• 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: class design issue
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: class design issue


  • Subject: Re: class design issue
  • From: Bob Savage <email@hidden>
  • Date: Wed, 30 Jan 2002 00:53:25 -0600

on 1/29/02 10:47 PM, email@hidden wrote:

> I didn't want MainController to know anything about the actual
> nib and window controller called BookController. So [book show]
> instantiates a single BookController calling initWithBook:self, which
> means now the controller has a pointer back to the Book, which seems
> ok. But of course the book now has a pointer to the BookController...
> circular references always make me nervous.

This shouldn't be a problem unless they both retain each other.

> The real problem occurs for me when the BookController needs to call
> some method on the MainController instance. BookController has no
> pointer to the MainController, and neither does the Book instance it
> references. In other similar cases, I solved the problem by making the
> class in question a singleton with a class method that instantiated the
> static instance and returned it so i could call methods on it. However,
> in this case, the class was loaded from MainMenu.nib and I can't get a
> global handle on it.

Actually if the "MainController" is the delegate for NSApplication, then
there is a pretty simple solution:

[ [[NSApplication sharedApplication] delegate] someMethod ];

Bob


References: 
 >class design issue (From: email@hidden)

  • Prev by Date: Re: Initializing an Array
  • Next by Date: Re: NSDictionary
  • Previous by thread: class design issue
  • Next by thread: Re: class design issue
  • Index(es):
    • Date
    • Thread