home *** CD-ROM | disk | FTP | other *** search
/ OpenStep 4.2J (Developer) / os42jdev.iso / NextDeveloper / Examples / Foundation / TCPTransport / RemoteTest.m < prev    next >
Text File  |  1996-04-17  |  1KB  |  49 lines

  1. /* RemoteTest.m created by blaine on Tue 16-Apr-1996 */
  2.  
  3. #import "RemoteTest.h"
  4.  
  5. @implementation RemoteTest
  6. - init {
  7.     [super init];
  8.     myHost = [[NSHost currentHost] retain];
  9.     otherObject = nil;
  10.     return self;
  11. }
  12.  
  13. - (void)dealloc {
  14.     [myHost release];
  15.     [super dealloc];
  16. }
  17.  
  18. - (NSHost *)host {
  19.     return myHost;
  20. }
  21.  
  22. - (NSDate *)date {
  23.     return [NSDate date];
  24. }
  25.  
  26. - (void)log:(NSString *)message {
  27.     NSLog(@"%@", message);
  28. }
  29.  
  30. - (void)setOtherObject:(NSObject *)anObject {
  31.     [anObject retain];    // in case it == otherObject & there is only 1 ref
  32.     [otherObject release];
  33.     otherObject = anObject;
  34. }
  35.  
  36. - (NSObject *)otherObject {
  37.     return [[otherObject retain] autorelease];
  38.         // most expensive but safest way to hand out an attribute
  39.         // Alternatives are: return otherObject, but if later someone
  40.         // does a setOtherObject the caller will be left with garbage
  41.         // Another alternative is to return otherObject here but do
  42.         // a [otherObject autorelease] in the setOtherObject: method.
  43.         // This works most of the time... but... fails if a setOtherObject:
  44.         // occurs after a new autorelease pool is formed then reclaimed, again
  45.         // leaving the caller holding garbage.
  46. }
  47.  
  48. @end
  49.