home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1994 June / NEBULA_SE.ISO / SourceCode / MiscKit / Headers / misckit / MiscClassVariable.h < prev    next >
Encoding:
Text File  |  1994-03-23  |  1.8 KB  |  52 lines

  1. //
  2. //    MiscClassVariable.m -- a class to implement true class variables
  3. //        Written by Mike Ferris Copyright (c) 1994 by Mike Ferris.
  4. //        Modified from original MOKit "MOClassVariable" class by Don Yacktman.
  5. //                Version 1.0.  All rights reserved.
  6. //
  7. //        This notice may not be removed from this source code.
  8. //
  9. //    This object is included in the MiscKit by permission from the author
  10. //    and its use is governed by the MiscKit license, found in the file
  11. //    "LICENSE.rtf" in the MiscKit distribution.  Please refer to that file
  12. //    for a list of all applicable permissions and restrictions.
  13. //    
  14.  
  15.  
  16. // About the MiscClassVariable Class...
  17. //
  18. // MiscClassVariable provides for better class variables than plain old 
  19. // static variables in the .m file.  You make a MiscClassVariable by
  20. // declaring a static variable, but then the class handles keeping
  21. // separate values of the variable for the class itself and for any of
  22. // its subclasses.  Values must be objects in the current implementation.
  23.  
  24. // Note that by using static variables in .m files containing categories,
  25. // you can simulate extra instance variables for categories of objects too!
  26. // Just cast the arguments like this:
  27. //        [MyNewInstanceVar getObjectForClass:(Class)self];
  28. // and it will use [self name] as the key to search for the variable.
  29. // You have to give your instances unique names for this to work...
  30. // (It might be better to have the implementation key off the id of
  31. // a class object/instance, but using names is less ObjC-implementation
  32. // dependant, which is probably a good thing.)
  33.  
  34. #import <appkit/appkit.h>
  35.  
  36. @interface MiscClassVariable:Object
  37. {
  38.     HashTable         *ht;
  39.     BOOL            doesFreeValues;
  40. }
  41.  
  42. + initialize;
  43.  
  44. - init;
  45. - initDoesFreeValues:(BOOL)flag;
  46. - free;
  47.  
  48. - setObject:obj forClass:(Class)class;
  49. - getObjectForClass:(Class)class;
  50.  
  51. @end
  52.