Skip navigation.
 
mlRe: How to Know the Mutators?
FROM : Chris Hanson
DATE : Fri Nov 29 18:22:01 2002

At 9:31 AM +0100 11/29/02, Philip Mötteli wrote:
>>What do you need this information for? You should probably make up
>>a convention for your own use and stick to that. But you can't rely
>>on Foundation or AppKit or anyone else doing the same.

>
>I'm in the process of writing an Objective-C interface for an
>OODBMS. When a method will change an instance variable, we have to
>test, if that object is already locked and otherwise lock it and
>afterwards propagating the changements forward to the DB.


You can approach this in a similar way to EOGenericRecord from the
Enterprise Objects Framework that some of us go on about.

EOGenericRecord overrides NSObject's implementation of Key-Value
Coding to keep all attributes for a class (as defined in its
EOClassDescription) in a dictionary.

Subclasses of EOGenericRecord typically have accessors that look like so:

  - (NSString *)foo {
    return [self storedValueForKey:@"foo"];
  }

  - (void)setFoo:(NSString *)value {
    [self takeStoredValue:value
                    forKey:@"foo];
  }

The reason for this is that when EOGenericRecord is told to take a
value for a key, it first does a [self willChange], which broadcasts
a message to all interested observers (like the object's editing
context, which needs to record snapshots for undo & database
transaction purposes) that the object will be changing.

EOF also let you use classes that weren't subclasses of
EOGenericRecord.  They just had to implement a bunch of the
EOGenericRecord functionality themselves, but they were then free to
use instance variables instead of a mutable dictionary for attribute
storage etc.

  -- Chris

--
Chris Hanson                      |  Email: <email_removed>
bDistributed.com, Inc.            |  Phone: +1-847-372-3955
Making Business Distributed      |  Fax:  +1-847-589-3738
http://bdistributed.com/          |  Personal Email: <email_removed>

Related mailsAuthorDate
mlHow to Know the Mutators? Philip Mötteli Nov 28, 16:59
mlRe: How to Know the Mutators? David Remahl Nov 28, 17:41
mlRe: How to Know the Mutators? Philip Mötteli Nov 29, 00:32
mlRe: How to Know the Mutators? Chris Hanson Nov 29, 18:22
mlRe: How to Know the Mutators? Helge Hess Dec 2, 03:27