home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / SourceCode / Database / OTC_EOFBetaExamples_V1.0 / EOFramework / DataSource / AppController.m < prev    next >
Encoding:
Text File  |  1994-05-25  |  2.8 KB  |  139 lines

  1. /*--------------------------------------------------------------------------
  2.  *
  3.  *     You may freely copy, distribute, and reuse the code in this example.
  4.  *     SHL Systemhouse disclaims any warranty of any kind, expressed or  
  5.  *    implied, as to its fitness for any particular use.
  6.  *
  7.  *
  8.  *    AppController
  9.  *
  10.  *    Inherits From:        NSObject
  11.  *
  12.  *    Conforms To:        None
  13.  *
  14.  *    Declared In:        AppController.h
  15.  *
  16.  *
  17.  *------------------------------------------------------------------------*/
  18. #import "AppController.h"
  19. #import "DataSource.h"
  20. #import "Motorcycle.h"
  21. #import "ScrollViewExtensions.h"
  22. #import <eointerface/EOController.h>
  23. #import <foundation/NSString.h>
  24.  
  25. #define print_trace [self console: [NSString stringWithFormat:\
  26. @"EOCONTROLLER  %s\n", sel_getName(_cmd)]]
  27.  
  28.  
  29.  
  30. @implementation AppController
  31.  
  32. /*--------------------------------------------------------------------------
  33.  *    Cover Methods for EOController Actions
  34.  *------------------------------------------------------------------------*/
  35. - fetch: sender
  36. {
  37.     sequence++;
  38.     print_trace;
  39.     [eoController fetch: sender];
  40.     return self;
  41. }
  42.  
  43.  
  44. - insert: sender
  45. {
  46.     sequence++;
  47.     print_trace;
  48.     [eoController insert: sender];
  49.     return self;
  50. }
  51.  
  52.  
  53. - delete: sender
  54. {
  55.     sequence++;
  56.     print_trace;
  57.     [eoController delete: sender];
  58.     return self;
  59. }
  60.  
  61.  
  62. - saveToObjects: sender
  63. {
  64.     sequence++;
  65.     print_trace;
  66.     [eoController saveToObjects: sender];
  67.     return self;
  68. }
  69.  
  70.  
  71. - saveToDataSource: sender
  72. {
  73.     sequence++;
  74.     print_trace;
  75.     [eoController saveToDataSource: sender];
  76.     return self;
  77. }
  78.  
  79.  
  80. - undo: sender
  81. {
  82.     sequence++;
  83.     print_trace;
  84.     [eoController undo: sender];
  85.     return self;
  86. }
  87.  
  88.  
  89. /*--------------------------------------------------------------------------
  90.  *    Printing Trace Information
  91.  *------------------------------------------------------------------------*/
  92. - console: (NSString *) aString
  93. {
  94.     static int    lastSequence = 0;
  95.     
  96.     if (sequence == 0) return self;
  97.  
  98.     if (lastSequence != sequence)
  99.         {
  100.         [console sprintf: "\n"];
  101.         lastSequence = sequence;
  102.         }
  103.         
  104.     [console sprintf: "[%d]  %s", sequence, [aString cString]];
  105.     return self;
  106. }
  107.  
  108.  
  109. /*--------------------------------------------------------------------------
  110.  *    Initialization
  111.  *------------------------------------------------------------------------*/
  112. - appDidInit: sender
  113. {
  114.     /* Initialize 'persistentStore' with a couple of objects */
  115.     
  116.     id    object;
  117.     
  118.     object = [dataSource createObject];
  119.     [object setMake: @"Honda"];
  120.     [object setModel: @"CBR 900RR"];
  121.     [object setPrice: @"8999.00"];
  122.     [object setPicture: [NXImage findImageNamed: "CBR900RR"]];
  123.     [dataSource insertObject: object];
  124.     
  125.     object = [dataSource createObject];
  126.     [object setMake: @"Ducati"];
  127.     [object setModel: @"900SS SP"];
  128.     [object setPrice: @"9750.00"];
  129.     [object setPicture: [NXImage findImageNamed: "Ducati900SS"]];
  130.     [dataSource insertObject: object];
  131.     
  132.     [dataSource saveObjects];
  133.     [self fetch: nil];
  134.     return self;
  135. }
  136.  
  137.  
  138. @end
  139.