Re: Notifications or singletons?
Re: Notifications or singletons?
- Subject: Re: Notifications or singletons?
- From: j o a r <email@hidden>
- Date: Mon, 7 Apr 2003 07:49:57 +0200
I think you've done the right thing. It is sometimes tricky to decide
when to tie objects together with notifications and when to use
stronger bonds. IMO you've made the right choice here, because when the
user requests to open a new inspector window a maximum of one existing
object, and a known object, is affected (0 objects if you allow for
multiple inspectors (1 object if you don't allow multiple inspectors on
the same record), 1 object if the inspector is shared).
As an example on when to use notifications: If you allow multiple
inspector / detail windows you might consider to implement
"WillDeleteRecord" / "DidDeleteRecord" notifications to use if the user
deletes an inspected entry - that would allow the inspector to close
it's window / update display on these events.
In this case you could still use a direct method call - if your
inspector class maintained a list of inspectors that could be traversed
as a response to these actions - but I would have used notifications.
j o a r
On Monday, Apr 7, 2003, at 01:12 Europe/Stockholm, Andrew Merenbach
wrote:
I'm working upon a small address-book-like application that maintains
a list of contacts and associated data. When a contact's name is
double-clicked in the main list, a new window opens with more detailed
information. I currently do this via a singleton: the detail window
has a shared instance that my master list calls, with the
currently-selected contact as an argument, and the contact window
controller loads the contact's information. Would this be better done
through notifications?
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.