+ (void)createAtomicChangeOfProperty:(NSString*)property onTarget:(id)target toNewValue:(id)newValue;
Instead of directly changing their internal fields when a setter is called,
transactional objects create a change object that will do this at a later point in
time when the change is committed. This static method is a helper for doing this in one step.
It will try to figure out the internal property accessor methods (see getterAccessorForProperty: and
setterAccessorForProperty:) and create a new instance of BNZAtomicPropertyChange.
Then it will fetch the current transaction from the BNZTransactionalNotificationCenter and add the
change to the transaction.
Name Description property the name of the property target the object that contains the property newValue the value to which the property should be set
+ (SEL)getterAccessorForProperty:(NSString*)property;
Objects that are using the BNZAtomicPropertyChange implementation's static helper methods
are required to offer a
Result: a selector constructed from the name of the property plus the suffix "_internal"
Name Description property the name of the property
- (id)initWithTarget:(id)target newValue:(id)newValue setterMethod:(SEL)setter getterMethod:(SEL)getter andChangeType:(id)type;
Inits the fields of the BNZAtomicPropertyChange
the oldValue field is retreived through the getterMethod.
Result: a BNZAtomicPropertyChange
Name Description target the target object of this change newValue the value the property should be changed to setterMethod an internal setter of the target to directly set the property getterMethod an internal getter of the target to directly get the property changeType a unique identifier identifying this type of change
- (id)initWithTarget:(id)target propertyName:(NSString*)property newValue:(id)newValue;
This initializer will try to figure out the getter and setter accessor methods
(see getterAccessorForProperty: and setterAccessorForProperty:) according to the property
name and construct a change type by calling proposedChangeTypeForProperty:ofTarget
and call the initWithTarget:newValue:setterMethod:getterMethod:andChangeType:
Result: a BNZAtomicPropertyChange
Name Description target the target object of this change property the name of the property that should be changed newValue the value the property should be changed to
Result: the value the property should have after committing the change- (id)newValue;
Result: the value of the property before the change- (id)oldValue;
+ (id)proposedChangeTypeForProperty:(NSString*)property ofClass:(Class)clazz;
Given that a property name is unique within a class, this method
constructs a unique identifier string for a property change by combining the
class name, the property name, and applying the suffix "Change".
Example: Class Person with a property "firstName" will produce: "PersonFirstNameChange"
Result: a unique change type
Name Description property name of the property that ought to be changed clazz a class that contains the property that should be changed
+ (id)proposedChangeTypeForProperty:(NSString*)property ofTarget:(id)target;
+ (SEL)setterAccessorForProperty:(NSString*)property;
Objects that are using the BNZAtomicPropertyChange implementation's static helper methods
are required to offer a set
Result: a selector constructed from the name of the property plus the prefix "set" and the suffix "_internal"
Name Description property the name of the property
+ (id)transactionalValueForProperty:(NSString*)property ofTarget:(id)target;
Objects that participate in uncommitted transactions need to return different values for
their fields to callers from different threads (i.e., hide uncommitted changes to other threads
and show them to the own thread). This method implements this behavior.
When called, it tries to find the last change of the given property in the transaction of the current
thread. If it finds one, it returns the [change newValue] and therefore "pretends that the change has already
been done" for the caller thread. If it doen't find any change of the property in
the current thread, it returns the real field value of the target as it is retrieved by the
getterAccessorForProperty:
Result: the current value of the property of this target in the calling thread
Name Description property the name of the property target the object that contains the property
(Last Updated 8/31/2006)