• 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: Global Access Controls ?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

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.

References: 
 >Global Access Controls ? (From: Chad Eckles <email@hidden>)

  • Prev by Date: 10.1.5 'root' process dies on log-out
  • Next by Date: Re: Quicktime Atoms
  • Previous by thread: Global Access Controls ?
  • Next by thread: Global Access Controls ?
  • Index(es):
    • Date
    • Thread