Re: class design issue
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