Re: Global Access Controls ?
Re: Global Access Controls ?
- Subject: Re: Global Access Controls ?
- From: Sherm Pendley <email@hidden>
- Date: Thu, 24 Apr 2003 23:00:27 -0400
On Thursday, April 24, 2003, at 05:21 PM, Chad Eckles wrote:
Hello I have a control that i want to define only onece and i want to be
able to use it in other classes without having to redefine it over an
over
an over again how can i do this ?
You may want to re-think your design.
Let's say you have an NSTextField that you're using as a status display.
Depending on what's going on in your program, it might appear at first
that any number of different objects may need to set the text in that
field, to reflect their status - but not so.
What I would do in a case like this is use notifications. An object that
wants to update the status display can create an NSNotification object,
set its name to something interesting such as "StatusUpdate", and set
its object to the string needing displayed. The controller that's in
charge of the status display would register itself as an observer for
those types of notifications, and respond to them by updating the status
text from the incoming notification object.
A "decoupled" approach like this simplifies maintenance. If you want to
change how status messages are displayed later - for example, you decide
to give users the option of appending them to a scrolling "log" window -
then the only class you'll need to update is the one handling the
incoming notifications.
sherm--
C programmers never die - they're just cast into void.
_______________________________________________
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.