home *** CD-ROM | disk | FTP | other *** search
/ OpenStep (Enterprise) / OpenStepENTCD.toast / OEDEV / EODEV.Z / CreditCard.m < prev    next >
Encoding:
Text File  |  1996-08-23  |  1.5 KB  |  53 lines

  1. /*
  2.         Copyright (c) 1996, NeXT Software, Inc.
  3.         All rights reserved.
  4.  
  5.         You may freely copy, distribute and reuse the code in this example.
  6.         NeXT disclaims any warranty of any kind, expressed or implied,
  7.         as to its fitness for any particular use.
  8. */
  9. #import "CreditCard.h"
  10.  
  11. @implementation CreditCard
  12.  
  13. - (void)awakeFromInsertionInEditingContext:(EOEditingContext *)ctx
  14. {
  15.     // Set default values for newly inserted objects in awake.
  16.     // No need to do willChange here since we're just being inserted
  17.     if (!authorizationDate) 
  18.         authorizationDate = [[NSCalendarDate date] retain];
  19.     if (!limit) 
  20.         limit = [[NSDecimalNumber decimalNumberWithString:@"150"] retain];
  21. }
  22.  
  23. - (NSDecimalNumber *)limit {
  24.     return limit;
  25. }
  26.  
  27. - (void)dealloc
  28. {
  29.     [authorizationDate release];
  30.     [authorizationNum release];
  31.     [cardNumber release];
  32.     [cardType release];
  33.     [member release];
  34.     [expirationDate release];
  35.     [limit release];
  36.     [super dealloc];
  37. }
  38.  
  39. - description { return [self eoDescription]; }
  40.  
  41. - (NSString *)inverseForRelationshipKey:(NSString *)relationshipKey
  42. {
  43.     // It's normally not necessary to explicitly define this method,
  44.     // since the EOModel does it for us (via EOClassDescription).  In
  45.     // this case EORelationship can't spot the inverse because we don't
  46.     // join on the same set of keys in the member and creditCard relationships
  47.     if ([relationshipKey isEqual:@"member"])
  48.         return @"creditCard";
  49.     return [super inverseForRelationshipKey:relationshipKey];
  50. }
  51.  
  52. @end
  53.