Annotation of Examples/EnterpriseObjects/QueryByExample/QBEPalette/DictionaryDataSource.m, revision 1.1.1.1

1.1       root        1: /* DictionaryDataSource.m:
                      2:  * You may freely copy, distribute, and reuse the code in this example.
                      3:  * NeXT disclaims any warranty of any kind, expressed or  implied, as to its
                      4:  * fitness for any particular use.
                      5:  *
                      6:  * Written by EO Development Team
                      7:  * Last modified 07/26/94 Mai Nguyen
                      8:  *
                      9:  * Example of a non-database data source implementation
                     10:  */
                     11: 
                     12: #import "DictionaryDataSource.h"
                     13: 
                     14: @implementation DictionaryDataSource
                     15: 
                     16: - init
                     17: {
                     18:     return [self initWithKeys: nil];
                     19: }
                     20: 
                     21: 
                     22: - initWithKeys: (NSArray *)k;
                     23: {
                     24:     [super init];
                     25:     array = [[NSMutableArray alloc] init];
                     26:     if (k)
                     27:        keys = [[NSArray alloc] initWithArray: k];
                     28:     return self;
                     29: }
                     30: 
                     31: - (void)dealloc
                     32: {
                     33:     [array release];
                     34:     [keys dealloc];
                     35:     [super dealloc];
                     36: }
                     37: 
                     38: /* Return a set of keys describing the data bearing objects */
                     39: - (NSArray *)keys
                     40: {
                     41:     return keys;
                     42: }
                     43: 
                     44: 
                     45: /* Returns a new data bearing object */
                     46: - createObject
                     47: {
                     48:     id anObject = [[NSMutableDictionary alloc] init];
                     49:     return anObject;
                     50: }
                     51: 
                     52: 
                     53: /* Inserts the object in the data source */
                     54: - (BOOL)insertObject:object
                     55: {
                     56:     [array addObject: object];
                     57:     return YES;
                     58: }
                     59: 
                     60: - (BOOL)canDelete
                     61: {
                     62:     return YES;
                     63: }
                     64: 
                     65: 
                     66: /* Removes the object from the data source */
                     67: - (BOOL)deleteObject:object
                     68: {
                     69:     [array removeObject: object];
                     70:     return YES;
                     71: }
                     72: 
                     73: /* Saves edits to the object */
                     74: - (BOOL)updateObject:object
                     75: {
                     76:     // NOOP
                     77:     return YES;
                     78: }
                     79: 
                     80: - (NSArray *)fetchObjects
                     81: {
                     82:     return array;
                     83: }
                     84: 
                     85: /* Saves insertions, removals and updates to storage */
                     86: - (BOOL)saveObjects
                     87: {
                     88:     return YES;
                     89: }
                     90: 
                     91: /* Since the DictionaryDataSource does not use an eomodel, this method
                     92:  * just returns the value.
                     93:  * No type coercion is needed.
                     94:  */
                     95: - coerceValue: value forKey: (NSString *)key
                     96: {
                     97:        return value;
                     98: }
                     99: 
                    100: @end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.